tracer-sh 0.2.2 → 0.2.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/package.json +1 -1
- package/packages/server/dist/{chunk-6QUU7TGZ.js → chunk-IKD3ICQK.js} +2 -0
- package/packages/server/dist/{chunk-OTYSD6PF.js → chunk-L7TO4UJ4.js} +2 -0
- package/packages/server/dist/{chunk-4VNS5WPM.js → chunk-WOL2ZWU7.js} +1 -0
- package/packages/server/dist/{chunk-7J2BYJNR.js → chunk-WUFQGSGW.js} +2 -1
- package/packages/server/dist/{chunk-5IQ4TST5.js → chunk-XFJVNMJI.js} +2 -0
- package/packages/server/dist/{domain-knowledge-WHIEZOOH.js → domain-knowledge-4AAER546.js} +3 -2
- package/packages/server/dist/{domain-knowledge-V6AENXZV.js → domain-knowledge-A3WXZ55R.js} +3 -2
- package/packages/server/dist/{domain-knowledge-5ZUPRLNB.js → domain-knowledge-CAD7MDFJ.js} +3 -2
- package/packages/server/dist/index.js +107 -29
- package/packages/server/dist/{token-4WRACUIQ.js → token-QV5VOVJ4.js} +3 -2
- package/packages/server/dist/token-util-DLXYCJR4.js +6 -0
- package/packages/web/dist/assets/{SearchableSelect-CGq3RJiX.js → SearchableSelect-DwcqGvga.js} +1 -1
- package/packages/web/dist/assets/{Settings-CSYYBQF1.js → Settings-V6P0atyS.js} +1 -1
- package/packages/web/dist/assets/{highlighted-body-OFNGDK62-CnIKGHSu.js → highlighted-body-OFNGDK62-BI81QblF.js} +1 -1
- package/packages/web/dist/assets/{index-DLQaH2AJ.css → index-CxrnanDH.css} +1 -1
- package/packages/web/dist/assets/index-XO-cs6YP.js +48 -0
- package/packages/web/dist/assets/{mermaid-GHXKKRXX-D9p_GS3a.js → mermaid-GHXKKRXX-mO3J4JDi.js} +3 -3
- package/packages/web/dist/index.html +2 -2
- package/packages/server/dist/token-util-NKFL6ZOU.js +0 -5
- package/packages/web/dist/assets/index-_7TPlTNo.js +0 -48
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
1
3
|
// src/providers/gcp/domain-knowledge.ts
|
|
2
4
|
var GCP_AUTH_STOP_RULE = `## Authentication Failure \u2014 STOP IMMEDIATELY
|
|
3
5
|
If any tool returns an authentication or permission error (e.g. "unauthenticated", "permission denied", "credentials", "401", "403", "UNAUTHENTICATED", "insufficient permissions"), **STOP ALL FURTHER TOOL CALLS** and report:
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
1
3
|
// src/providers/posthog/domain-knowledge.ts
|
|
2
4
|
var POSTHOG_AUTH_STOP_RULE = `## Authentication Failure \u2014 STOP IMMEDIATELY
|
|
3
5
|
If any query returns an authentication or permission error (e.g. "Invalid personal API key", "401", "403", "Unauthorized", "Forbidden"), **STOP ALL FURTHER TOOL CALLS** and report:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
__commonJS,
|
|
3
4
|
__require
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WOL2ZWU7.js";
|
|
5
6
|
|
|
6
7
|
// ../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-error.js
|
|
7
8
|
var require_token_error = __commonJS({
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
1
3
|
// src/providers/newrelic/domain-knowledge.ts
|
|
2
4
|
var NR_AUTH_STOP_RULE = `## Authentication Failure \u2014 STOP IMMEDIATELY
|
|
3
5
|
If any query returns an authentication or permission error (e.g. "Invalid API key", "401", "403", "Unauthorized"), **STOP ALL FURTHER TOOL CALLS** and report:
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
NR_AUTH_STOP_RULE,
|
|
3
4
|
NR_DOMAIN_KNOWLEDGE,
|
|
4
5
|
NR_INSIDE_OUT_DEBUGGING,
|
|
5
6
|
NR_SERVICE_HEALTH_RUNBOOK
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-XFJVNMJI.js";
|
|
8
|
+
import "./chunk-WOL2ZWU7.js";
|
|
8
9
|
export {
|
|
9
10
|
NR_AUTH_STOP_RULE,
|
|
10
11
|
NR_DOMAIN_KNOWLEDGE,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
GCP_AUTH_STOP_RULE,
|
|
3
4
|
GCP_CROSS_SIGNAL,
|
|
@@ -5,8 +6,8 @@ import {
|
|
|
5
6
|
GCP_INSIDE_OUT_DEBUGGING,
|
|
6
7
|
GCP_PAGE_SIZE_RULE,
|
|
7
8
|
GCP_TOOL_REFERENCE
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-IKD3ICQK.js";
|
|
10
|
+
import "./chunk-WOL2ZWU7.js";
|
|
10
11
|
export {
|
|
11
12
|
GCP_AUTH_STOP_RULE,
|
|
12
13
|
GCP_CROSS_SIGNAL,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
POSTHOG_AUTH_STOP_RULE,
|
|
3
4
|
POSTHOG_DOMAIN_KNOWLEDGE,
|
|
4
5
|
POSTHOG_INSIDE_OUT_DEBUGGING
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-L7TO4UJ4.js";
|
|
7
|
+
import "./chunk-WOL2ZWU7.js";
|
|
7
8
|
export {
|
|
8
9
|
POSTHOG_AUTH_STOP_RULE,
|
|
9
10
|
POSTHOG_DOMAIN_KNOWLEDGE,
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
require_auth_errors,
|
|
3
4
|
require_token_error,
|
|
4
5
|
require_token_util
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WUFQGSGW.js";
|
|
6
7
|
import {
|
|
7
8
|
NR_AUTH_STOP_RULE,
|
|
8
9
|
NR_DOMAIN_KNOWLEDGE,
|
|
9
10
|
NR_INSIDE_OUT_DEBUGGING
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XFJVNMJI.js";
|
|
11
12
|
import {
|
|
12
13
|
GCP_AUTH_STOP_RULE,
|
|
13
14
|
GCP_CROSS_SIGNAL,
|
|
14
15
|
GCP_DOMAIN_KNOWLEDGE,
|
|
15
16
|
GCP_INSIDE_OUT_DEBUGGING,
|
|
16
17
|
GCP_PAGE_SIZE_RULE
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IKD3ICQK.js";
|
|
18
19
|
import {
|
|
19
20
|
POSTHOG_AUTH_STOP_RULE,
|
|
20
21
|
POSTHOG_DOMAIN_KNOWLEDGE,
|
|
21
22
|
POSTHOG_INSIDE_OUT_DEBUGGING
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-L7TO4UJ4.js";
|
|
23
24
|
import {
|
|
24
25
|
__commonJS,
|
|
25
26
|
__export,
|
|
26
27
|
__toESM
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-WOL2ZWU7.js";
|
|
28
29
|
|
|
29
30
|
// ../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
|
|
30
31
|
var require_get_context = __commonJS({
|
|
@@ -100,8 +101,8 @@ var require_get_vercel_oidc_token = __commonJS({
|
|
|
100
101
|
}
|
|
101
102
|
try {
|
|
102
103
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
103
|
-
await import("./token-util-
|
|
104
|
-
await import("./token-
|
|
104
|
+
await import("./token-util-DLXYCJR4.js"),
|
|
105
|
+
await import("./token-QV5VOVJ4.js")
|
|
105
106
|
]);
|
|
106
107
|
if (!token || isExpired(getTokenPayload(token), options?.expirationBufferMs)) {
|
|
107
108
|
await refreshToken(options);
|
|
@@ -16591,6 +16592,11 @@ var CONFIG = {
|
|
|
16591
16592
|
restartExitCode: 75,
|
|
16592
16593
|
// ── Updater ──
|
|
16593
16594
|
npmViewTimeoutMs: 1e4,
|
|
16595
|
+
/** `npm install -g` can take a while (network + native rebuilds), so allow more headroom. */
|
|
16596
|
+
npmInstallTimeoutMs: 12e4,
|
|
16597
|
+
/** Buffer cap for `npm install -g` output; well above the 1MB default so a noisy
|
|
16598
|
+
* but successful install (native rebuild logs) isn't misreported as a failure. */
|
|
16599
|
+
npmInstallMaxBufferBytes: 16 * 1024 * 1024,
|
|
16594
16600
|
// ── Dashboard defaults ──
|
|
16595
16601
|
widgetDefaultWidth: 6,
|
|
16596
16602
|
widgetDefaultHeight: 6,
|
|
@@ -16618,11 +16624,14 @@ function subAgentModelKey(providerType) {
|
|
|
16618
16624
|
// src/updater.ts
|
|
16619
16625
|
import { exec } from "child_process";
|
|
16620
16626
|
import { readFileSync } from "fs";
|
|
16621
|
-
import { join, dirname } from "path";
|
|
16627
|
+
import { join, dirname, sep } from "path";
|
|
16622
16628
|
import { fileURLToPath } from "url";
|
|
16623
16629
|
var RESTART_EXIT_CODE = CONFIG.restartExitCode;
|
|
16624
16630
|
var cachedStatus = null;
|
|
16625
|
-
|
|
16631
|
+
var cachedPackageInfo = null;
|
|
16632
|
+
function resolvePackage() {
|
|
16633
|
+
if (cachedPackageInfo) return cachedPackageInfo;
|
|
16634
|
+
let info = { root: null, version: "unknown" };
|
|
16626
16635
|
try {
|
|
16627
16636
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16628
16637
|
for (const candidate of [
|
|
@@ -16632,13 +16641,29 @@ function readCurrentVersion() {
|
|
|
16632
16641
|
]) {
|
|
16633
16642
|
try {
|
|
16634
16643
|
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
16635
|
-
if (pkg.name === "tracer-sh" && pkg.version)
|
|
16644
|
+
if (pkg.name === "tracer-sh" && pkg.version) {
|
|
16645
|
+
info = { root: dirname(candidate), version: pkg.version };
|
|
16646
|
+
break;
|
|
16647
|
+
}
|
|
16636
16648
|
} catch {
|
|
16637
16649
|
}
|
|
16638
16650
|
}
|
|
16639
16651
|
} catch {
|
|
16640
16652
|
}
|
|
16641
|
-
|
|
16653
|
+
cachedPackageInfo = info;
|
|
16654
|
+
return info;
|
|
16655
|
+
}
|
|
16656
|
+
function readCurrentVersion() {
|
|
16657
|
+
return resolvePackage().version;
|
|
16658
|
+
}
|
|
16659
|
+
function detectInstallMethod(root) {
|
|
16660
|
+
if (!root) return "dev";
|
|
16661
|
+
if (root.includes(`${sep}_npx${sep}`)) return "npx";
|
|
16662
|
+
if (root.includes(`${sep}node_modules${sep}tracer-sh`)) return "global";
|
|
16663
|
+
return "dev";
|
|
16664
|
+
}
|
|
16665
|
+
function getInstallMethod() {
|
|
16666
|
+
return detectInstallMethod(resolvePackage().root);
|
|
16642
16667
|
}
|
|
16643
16668
|
function isNewerVersion(latest, current) {
|
|
16644
16669
|
const parse4 = (v) => v.replace(/^v/, "").split(".").map(Number);
|
|
@@ -16665,29 +16690,66 @@ function getUpdateStatus() {
|
|
|
16665
16690
|
return {
|
|
16666
16691
|
available: false,
|
|
16667
16692
|
currentVersion: readCurrentVersion(),
|
|
16668
|
-
latestVersion: null
|
|
16693
|
+
latestVersion: null,
|
|
16694
|
+
method: getInstallMethod()
|
|
16669
16695
|
};
|
|
16670
16696
|
}
|
|
16671
16697
|
function checkForUpdateBackground() {
|
|
16672
16698
|
const current = readCurrentVersion();
|
|
16699
|
+
const method = getInstallMethod();
|
|
16700
|
+
const unavailable = () => ({ available: false, currentVersion: current, latestVersion: null, method });
|
|
16673
16701
|
if (current === "unknown") {
|
|
16674
|
-
cachedStatus =
|
|
16702
|
+
cachedStatus = unavailable();
|
|
16675
16703
|
return;
|
|
16676
16704
|
}
|
|
16677
16705
|
fetchLatestNpmVersion().then((latest) => {
|
|
16678
16706
|
if (!latest) {
|
|
16679
|
-
cachedStatus =
|
|
16707
|
+
cachedStatus = unavailable();
|
|
16680
16708
|
return;
|
|
16681
16709
|
}
|
|
16682
16710
|
const available = isNewerVersion(latest, current);
|
|
16683
|
-
cachedStatus = { available, currentVersion: current, latestVersion: latest };
|
|
16711
|
+
cachedStatus = { available, currentVersion: current, latestVersion: latest, method };
|
|
16684
16712
|
if (available) {
|
|
16685
|
-
|
|
16713
|
+
const hint = method === "global" ? "click the version in the sidebar to update from the app" : method === "npx" ? "re-run: npx tracer-sh@latest" : "git pull && pnpm install && pnpm build";
|
|
16714
|
+
console.log(`Update available: v${current} \u2192 v${latest} (${hint})`);
|
|
16686
16715
|
}
|
|
16687
16716
|
}).catch(() => {
|
|
16688
|
-
cachedStatus =
|
|
16717
|
+
cachedStatus = unavailable();
|
|
16689
16718
|
});
|
|
16690
16719
|
}
|
|
16720
|
+
function performSelfUpdate() {
|
|
16721
|
+
const method = getInstallMethod();
|
|
16722
|
+
if (method !== "global") {
|
|
16723
|
+
return Promise.resolve({
|
|
16724
|
+
ok: false,
|
|
16725
|
+
method,
|
|
16726
|
+
error: method === "npx" ? "Running via npx, which can't be updated in place. Re-run `npx tracer-sh@latest` to get the latest version." : "Running from a local source checkout, so in-app update is disabled."
|
|
16727
|
+
});
|
|
16728
|
+
}
|
|
16729
|
+
return new Promise((resolve4) => {
|
|
16730
|
+
exec(
|
|
16731
|
+
// Quiet flags keep output small (a verbose install can otherwise overflow
|
|
16732
|
+
// the stdout buffer and look like a failure); maxBuffer adds headroom for
|
|
16733
|
+
// native rebuild logs so a successful install is never misreported.
|
|
16734
|
+
"npm install -g tracer-sh@latest --no-fund --no-audit --loglevel=error",
|
|
16735
|
+
{ encoding: "utf-8", timeout: CONFIG.npmInstallTimeoutMs, maxBuffer: CONFIG.npmInstallMaxBufferBytes },
|
|
16736
|
+
(err, _stdout, stderr) => {
|
|
16737
|
+
if (err) {
|
|
16738
|
+
resolve4({ ok: false, method, error: (stderr || "").trim() || err.message });
|
|
16739
|
+
return;
|
|
16740
|
+
}
|
|
16741
|
+
resolve4({ ok: true, method });
|
|
16742
|
+
}
|
|
16743
|
+
);
|
|
16744
|
+
});
|
|
16745
|
+
}
|
|
16746
|
+
var restartHandler = null;
|
|
16747
|
+
function setRestartHandler(fn) {
|
|
16748
|
+
restartHandler = fn;
|
|
16749
|
+
}
|
|
16750
|
+
function requestRestart() {
|
|
16751
|
+
restartHandler?.();
|
|
16752
|
+
}
|
|
16691
16753
|
|
|
16692
16754
|
// src/db/client.ts
|
|
16693
16755
|
import { homedir } from "os";
|
|
@@ -46134,9 +46196,9 @@ function createDeleteMemoryTool(memoryExecute, opts) {
|
|
|
46134
46196
|
|
|
46135
46197
|
// src/agents/utility/memory-domain-knowledge.ts
|
|
46136
46198
|
var DOMAIN_LOADERS = {
|
|
46137
|
-
newrelic: async () => (await import("./domain-knowledge-
|
|
46138
|
-
gcp: async () => (await import("./domain-knowledge-
|
|
46139
|
-
posthog: async () => (await import("./domain-knowledge-
|
|
46199
|
+
newrelic: async () => (await import("./domain-knowledge-4AAER546.js")).NR_DOMAIN_KNOWLEDGE,
|
|
46200
|
+
gcp: async () => (await import("./domain-knowledge-A3WXZ55R.js")).GCP_DOMAIN_KNOWLEDGE,
|
|
46201
|
+
posthog: async () => (await import("./domain-knowledge-CAD7MDFJ.js")).POSTHOG_DOMAIN_KNOWLEDGE
|
|
46140
46202
|
};
|
|
46141
46203
|
async function getDomainKnowledge(providerType) {
|
|
46142
46204
|
const loader = DOMAIN_LOADERS[providerType];
|
|
@@ -49595,14 +49657,14 @@ function fmtVal2(v) {
|
|
|
49595
49657
|
function mdTable(headers, rows) {
|
|
49596
49658
|
if (rows.length === 0) return "(empty)";
|
|
49597
49659
|
const hdr = `| ${headers.join(" | ")} |`;
|
|
49598
|
-
const
|
|
49660
|
+
const sep2 = `| ${headers.map(() => "---").join(" | ")} |`;
|
|
49599
49661
|
const body = rows.map(
|
|
49600
49662
|
(r) => `| ${r.map(
|
|
49601
49663
|
(c) => String(c).replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, " ")
|
|
49602
49664
|
).join(" | ")} |`
|
|
49603
49665
|
).join("\n");
|
|
49604
49666
|
return `${hdr}
|
|
49605
|
-
${
|
|
49667
|
+
${sep2}
|
|
49606
49668
|
${body}`;
|
|
49607
49669
|
}
|
|
49608
49670
|
function trunc(s, max = 100) {
|
|
@@ -56973,8 +57035,21 @@ var updateRouter = router({
|
|
|
56973
57035
|
return {
|
|
56974
57036
|
available: status.available,
|
|
56975
57037
|
currentVersion: status.currentVersion,
|
|
56976
|
-
latestVersion: status.latestVersion
|
|
57038
|
+
latestVersion: status.latestVersion,
|
|
57039
|
+
method: status.method,
|
|
57040
|
+
// Only a global install can be upgraded in place from the app.
|
|
57041
|
+
canSelfUpdate: status.method === "global"
|
|
56977
57042
|
};
|
|
57043
|
+
}),
|
|
57044
|
+
// Upgrade a global install in place, then trigger a graceful restart so the
|
|
57045
|
+
// launcher re-spawns the new server. The restart is deferred to the next tick
|
|
57046
|
+
// so this response flushes to the client before shutdown begins.
|
|
57047
|
+
perform: publicProcedure.mutation(async () => {
|
|
57048
|
+
const result = await performSelfUpdate();
|
|
57049
|
+
if (result.ok) {
|
|
57050
|
+
setImmediate(() => requestRestart());
|
|
57051
|
+
}
|
|
57052
|
+
return result;
|
|
56978
57053
|
})
|
|
56979
57054
|
});
|
|
56980
57055
|
|
|
@@ -58830,19 +58905,22 @@ Port ${CONFIG.port} is already in use. Run: lsof -ti :${CONFIG.port} | xargs kil
|
|
|
58830
58905
|
}
|
|
58831
58906
|
process.exit(1);
|
|
58832
58907
|
});
|
|
58833
|
-
const shutdown = async () => {
|
|
58834
|
-
const timeout = setTimeout(() => process.exit(1), CONFIG.shutdownGracePeriodMs);
|
|
58908
|
+
const shutdown = async (code = 0) => {
|
|
58909
|
+
const timeout = setTimeout(() => process.exit(code === 0 ? 1 : code), CONFIG.shutdownGracePeriodMs);
|
|
58835
58910
|
await scheduler.stop();
|
|
58836
58911
|
for (const p of providers.getAllProviders()) {
|
|
58837
58912
|
await p.dispose().catch(() => {
|
|
58838
58913
|
});
|
|
58839
58914
|
}
|
|
58840
58915
|
clearTimeout(timeout);
|
|
58841
|
-
process.exit(
|
|
58916
|
+
process.exit(code);
|
|
58842
58917
|
};
|
|
58843
|
-
process.on("SIGINT", shutdown);
|
|
58844
|
-
process.on("SIGTERM", shutdown);
|
|
58845
|
-
process.on("SIGHUP", shutdown);
|
|
58918
|
+
process.on("SIGINT", () => shutdown());
|
|
58919
|
+
process.on("SIGTERM", () => shutdown());
|
|
58920
|
+
process.on("SIGHUP", () => shutdown());
|
|
58921
|
+
setRestartHandler(() => {
|
|
58922
|
+
void shutdown(CONFIG.restartExitCode);
|
|
58923
|
+
});
|
|
58846
58924
|
}
|
|
58847
58925
|
main().catch((err) => {
|
|
58848
58926
|
console.error("Failed to start Tracer server:", err);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
require_token_error,
|
|
3
4
|
require_token_util
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WUFQGSGW.js";
|
|
5
6
|
import {
|
|
6
7
|
__commonJS
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WOL2ZWU7.js";
|
|
8
9
|
|
|
9
10
|
// ../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
|
|
10
11
|
var require_token = __commonJS({
|
package/packages/web/dist/assets/{SearchableSelect-CGq3RJiX.js → SearchableSelect-DwcqGvga.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q,r as s,j as r}from"./index-
|
|
1
|
+
import{a as q,r as s,j as r}from"./index-XO-cs6YP.js";var P=q();function $(c){const n=c?`tracer:starred:${c}`:null,[i,S]=s.useState(()=>{if(!n)return new Set;try{const a=localStorage.getItem(n);return a?new Set(JSON.parse(a)):new Set}catch{return new Set}});return[i,a=>{S(u=>{const t=new Set(u);return t.has(a)?t.delete(a):t.add(a),n&&localStorage.setItem(n,JSON.stringify([...t])),t})}]}function I({options:c,value:n,onChange:i,placeholder:S="Select...",storageKey:v,fitContent:a,disabled:u}){const[t,l]=s.useState(!1),[w,y]=s.useState(""),f=s.useRef(null),j=s.useRef(null),N=s.useRef(null),g=s.useRef(null),[x,C]=$(v),[m,L]=s.useState({top:0,left:0,minWidth:0});s.useEffect(()=>{if(!t)return;const e=d=>{f.current?.contains(d.target)||j.current?.contains(d.target)||l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]);const R=s.useCallback(()=>{if(!f.current)return;const e=f.current.getBoundingClientRect();L({top:e.bottom+4,left:e.left,minWidth:e.width})},[]);s.useEffect(()=>{t&&(R(),y(""),requestAnimationFrame(()=>N.current?.focus()))},[t,R]);const h=c.find(e=>e.value===n),p=s.useMemo(()=>{const e=w.toLowerCase();return[...e?c.filter(o=>o.label.toLowerCase().includes(e)||o.value.toLowerCase().includes(e)):c].sort((o,b)=>{const k=x.has(o.value)?0:1,E=x.has(b.value)?0:1;return k!==E?k-E:o.label.localeCompare(b.label)})},[c,w,x]);s.useEffect(()=>{if(t&&n&&g.current){const e=g.current.querySelector(`[data-value="${CSS.escape(n)}"]`);e&&e.scrollIntoView({block:"nearest"})}},[t,n]);const W=t?P.createPortal(r.jsxs("div",{ref:j,className:"fixed z-[100] bg-white border border-[#d4d2cd] rounded shadow-lg",style:{top:m.top,left:m.left,minWidth:m.minWidth,width:a?"max-content":m.minWidth},children:[r.jsx("div",{className:"p-1.5 border-b border-[#e8e6e1]",children:r.jsx("input",{ref:N,type:"text",value:w,onChange:e=>y(e.target.value),placeholder:"Search...",className:"w-full px-2 py-1.5 text-xs text-[#2c2c2c] font-sans bg-[#f5f4f0] border border-[#e8e6e1] rounded focus:outline-none focus:border-[#2b5ea7] placeholder:text-[#9c9890]",onKeyDown:e=>{e.key==="Escape"&&l(!1),e.key==="Enter"&&p.length>0&&(i(p[0].value),l(!1))}})}),r.jsx("div",{ref:g,className:"max-h-[280px] overflow-y-auto",children:p.length===0?r.jsx("div",{className:"px-3 py-3 text-xs text-[#9c9890] text-center",children:"No projects found"}):p.map(e=>{const d=e.value===n,o=x.has(e.value);return r.jsxs("div",{"data-value":e.value,className:`flex items-center gap-1.5 px-2 py-1.5 text-xs font-sans cursor-pointer transition-colors ${d?"bg-[#2b5ea7]/10 text-[#2b5ea7]":"text-[#2c2c2c] hover:bg-[#f5f4f0]"}`,onClick:()=>{i(e.value),l(!1)},children:[r.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),C(e.value)},className:`shrink-0 w-4 h-4 flex items-center justify-center text-[10px] transition-colors ${o?"text-[#d4a017]":"text-[#d4d2cd] hover:text-[#9c9890]"}`,title:o?"Unstar":"Star to pin to top",children:o?"★":"☆"}),r.jsx("span",{className:a?"whitespace-nowrap":"truncate flex-1",children:e.label})]},e.value)})})]}),document.body):null;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:f,type:"button",onClick:()=>!u&&l(!t),disabled:u,className:"w-full bg-white border border-[#d4d2cd] rounded px-3 py-2 text-xs text-[#2c2c2c] font-sans text-left flex items-center justify-between focus:outline-none focus:border-[#2b5ea7] hover:border-[#b0ada6] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[r.jsx("span",{className:h?"text-[#2c2c2c] truncate":"text-[#9c9890]",children:h?h.displayLabel??h.label:S}),r.jsx("span",{className:"text-[#9c9890] text-[10px] ml-2 shrink-0 transition-transform duration-200",style:{transform:t?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),W]})}export{I as S,P as r,$ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as p,r as g,j as e,S as T,c as _,b as i,C as K,A as B,u as ee,d as se,W as q,M as te}from"./index-_7TPlTNo.js";import{S as ne}from"./SearchableSelect-CGq3RJiX.js";function Z({type:s,label:n}){const o=p.useUtils(),{data:a,isLoading:c}=p.settings.getApiKey.useQuery(s),m=p.settings.saveApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),x=p.settings.removeApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),[d,r]=g.useState(!1),[h,l]=g.useState(""),[f,v]=g.useState(!1);async function N(){await m.mutateAsync({type:s,apiKey:h}),l(""),r(!1)}async function u(){await x.mutateAsync(s),r(!1),v(!1)}return c?e.jsx("div",{className:"px-4 py-3",children:e.jsx(T,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium w-24 shrink-0",children:n}),e.jsx("span",{className:i.maskedKey+" flex-1 truncate",style:a?{color:_.success}:void 0,children:a?a.maskedApiKey:"Not configured"}),!d&&e.jsx("button",{onClick:()=>{l(""),r(!0)},className:i.secondaryBtn+" text-xs px-3 py-1",children:a?"Edit":"Add"})]}),d&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[e.jsx("input",{type:h?"password":"text",value:h,onChange:b=>l(b.target.value),placeholder:a?.maskedApiKey??"Enter API key",className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:N,disabled:!h||m.isPending,className:i.primaryBtn+" text-xs px-3 py-1",children:m.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:m.isPending,className:i.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),a&&e.jsx("button",{onClick:()=>v(!0),disabled:x.isPending,className:i.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(K,{open:f,title:"Remove API key",message:`Remove the ${n} API key?`,confirmLabel:"Remove",onConfirm:u,onCancel:()=>v(!1)})]})}function ie({configuredProviders:s}){return e.jsx("div",{className:"border-t border-[#e8e6e1]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:i.tableHeaderRow,children:[e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:B.map(n=>{const o=s.has(n.provider);return e.jsxs("tr",{style:o?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:n.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:n.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.outputPrice.toFixed(2)]})]},n.modelId)})})]})})}function ae(){const[s,n]=g.useState(!1),o=ee();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"max-w-lg bg-white border border-[#d4d2cd] rounded divide-y divide-[#e8e6e1] overflow-hidden",children:[e.jsx(Z,{type:"anthropic",label:"Anthropic"}),e.jsx(Z,{type:"google",label:"Google AI"})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center justify-between px-4 py-3 text-sm text-[#666666] hover:bg-[#f5f4f0] transition-colors font-sans",children:[e.jsx("span",{className:"font-medium",children:"Model Pricing"}),e.jsx("span",{className:"text-xs transition-transform duration-200",style:{transform:s?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),s&&e.jsx(ie,{configuredProviders:o})]})]})}function oe({status:s,label:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${i.statusDot[s]}`}),n&&e.jsx("span",{className:i.statusLabel,children:n})]})}const U=`${B[1]?.provider??B[0].provider}:${B[1]?.modelId??B[0].modelId}`;function le({providerType:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.settings.getSubAgentModel.useQuery(s),c=p.settings.saveSubAgentModel.useMutation({onSuccess:()=>n.settings.getSubAgentModel.invalidate(s)}),m=se(),x=o?`${o.provider}:${o.modelId}`:U,d=m.some(l=>`${l.provider}:${l.modelId}`===x),r=d?x:`${m[0].provider}:${m[0].modelId}`;if(g.useEffect(()=>{!a&&o&&!d&&c.mutate({providerType:s,model:null})},[a,d]),a)return null;function h(l){if(l===U&&!o)return;const f=m.find(v=>`${v.provider}:${v.modelId}`===l);f&&(l===U?c.mutate({providerType:s,model:null}):c.mutate({providerType:s,model:{provider:f.provider,modelId:f.modelId}}))}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Model"}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("select",{value:r,onChange:l=>h(l.target.value),disabled:c.isPending,className:"w-full appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-7 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans disabled:opacity-50 disabled:cursor-not-allowed",children:m.map(l=>e.jsx("option",{value:`${l.provider}:${l.modelId}`,children:l.modelId},`${l.provider}:${l.modelId}`))}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]})}function re({existingConfig:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.provider.listGcpProjects.useQuery(void 0,{staleTime:q.updateCheckStaleTimeMs}),c=p.provider.saveConfig.useMutation({onSuccess:()=>{n.provider.getConfigs.invalidate(),n.provider.list.invalidate()}}),m=g.useMemo(()=>(o??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[o]),x=s.projectId??"";function d(r){r!==x&&c.mutate({type:"gcp",config:{...s,projectId:r}})}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(ne,{options:m,value:x,onChange:d,placeholder:a?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:a||c.isPending})})]})}function ce({checked:s,onChange:n,disabled:o,"aria-label":a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:o,onClick:()=>n(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${o?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s?"translate-x-[18px]":"translate-x-[3px]"}`})})}function de({type:s,label:n,connected:o,configured:a,onConfigure:c,onToggle:m,togglePending:x,toggleError:d,pingError:r,hasConfigFields:h,existingConfig:l}){const f=a||o;return e.jsxs("div",{className:i.settingsCard+" w-80",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{checked:a,onChange:v=>{v&&h?c():m(v)},disabled:x}),e.jsx("span",{className:"font-medium",children:n}),f?e.jsx(oe,{status:o?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${i.secondaryBtn} ${a&&h?"":"invisible"}`,children:"Edit"})]}),f&&e.jsx(le,{providerType:s}),f&&s==="gcp"&&l&&e.jsx(re,{existingConfig:l}),r&&!o&&e.jsx("p",{className:i.warnText+" mt-2",children:r}),d&&e.jsx("p",{className:i.errorText+" mt-2",children:d})]})}function H(s,n){return!!s&&!!n&&s===n}function ue({open:s,label:n,configFields:o,formValues:a,onFormChange:c,existingConfig:m,saveResult:x,savePending:d,configured:r,onSave:h,onClose:l,onRemove:f}){const v=o.some(u=>u.required!==!1&&u.type==="password"&&H(a[u.key],m?.[u.key])),N=o.some(u=>u.required!==!1&&!a[u.key]);return e.jsxs(te,{open:s,onClose:l,children:[e.jsxs("div",{className:i.dialogTitle+" text-base mb-4",children:["Configure ",n]}),e.jsx("div",{className:"space-y-3",children:o.map(u=>{const b=u.type==="password"&&H(a[u.key],m?.[u.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:i.sectionTitle,children:[u.label,u.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:u.type==="password"&&a[u.key]&&!b?"password":"text",value:a[u.key]??"",onChange:S=>c(u.key,S.target.value),onFocus:S=>{b&&S.target.select()},placeholder:`Enter ${u.label.toLowerCase()}`,className:`${i.input} ${b?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},u.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:h,disabled:N||v||d,className:i.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:l,disabled:d,className:i.secondaryBtn,children:"Cancel"}),r&&e.jsx("button",{onClick:f,disabled:d,className:i.dangerBtn,children:"Remove"})]}),v&&!d&&!x&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),x&&e.jsx("div",{className:`mt-3 ${x.success?i.successText:i.errorText}`,children:x.success?"Connected successfully":x.error||"Connection failed"})]})}function me(s,n){const o={};for(const a of s)o[a.key]=n?.[a.key]??"";return o}function xe(){const s=p.useUtils(),{data:n,isLoading:o}=p.provider.list.useQuery(),{data:a,isLoading:c}=p.provider.getConfigs.useQuery(),{data:m,isLoading:x}=p.provider.getRegisteredTypes.useQuery(),{data:d}=p.provider.ping.useQuery(void 0,{staleTime:q.sessionStaleTimeMs,refetchOnMount:"always"}),r=p.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),h=p.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[l,f]=g.useState(null),[v,N]=g.useState({}),[u,b]=g.useState(null),[S,A]=g.useState(null),[k,j]=g.useState({});function P(t){const y=a?.find(w=>w.type===t),C=m?.find(w=>w.type===t);N(me(C?.configFields??[],y?.config)),b(null),f(t)}function E(){f(null),N({}),b(null)}async function R(t){b(null);try{const y=await r.mutateAsync({type:t,config:v});b(y),y.success&&(f(null),N({}))}catch{b({success:!1,error:"Failed to save configuration"})}}async function z(t,y){if(y){j(C=>{const w={...C};return delete w[t],w});try{const C=await r.mutateAsync({type:t,config:{}});C.success||j(w=>({...w,[t]:C.error??"Connection failed"}))}catch{j(C=>({...C,[t]:"Failed to save configuration"}))}}else A(t)}async function F(t){await h.mutateAsync(t),f(null),N({}),b(null),A(null)}const O=o||c||x,$=m??[];if(O)return e.jsx(T,{size:"lg",centered:!0});const M=l?$.find(t=>t.type===l):null,D=l?a?.find(t=>t.type===l):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:$.map(({type:t,label:y,configFields:C})=>{const w=n?.find(I=>I.type===t),Q=a?.find(I=>I.type===t),W=!!Q,L=d?.find(I=>I.type===t),Y=L?L.ok:!!w?.connected,J=C.length>0,X=L&&!L.ok?L.error:void 0;return e.jsx(de,{type:t,label:y,connected:Y,configured:W,onConfigure:()=>P(t),onToggle:I=>z(t,I),togglePending:r.isPending||h.isPending,toggleError:k[t],pingError:X,hasConfigFields:J,existingConfig:Q?.config},t)})}),l&&M&&e.jsx(ue,{open:!0,label:M.label,configFields:M.configFields,formValues:v,onFormChange:(t,y)=>N(C=>({...C,[t]:y})),existingConfig:D?.config??null,saveResult:u,savePending:r.isPending,configured:!!D,onSave:()=>R(l),onClose:E,onRemove:()=>A(l)}),e.jsx(K,{open:S!==null,title:"Disable provider",message:`Disable ${$.find(t=>t.type===S)?.label??S}?`,confirmLabel:"Disable",onConfirm:()=>{S&&F(S)},onCancel:()=>A(null)})]})}function pe({memory:s,editingId:n,editNote:o,setEditNote:a,onUpdate:c,onCancelEdit:m,onStartEdit:x,onDelete:d,updatePending:r,removePending:h}){return e.jsxs("li",{className:"flex items-start justify-between gap-3 py-1.5 border-b border-[#d4d2cd] last:border-b-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:n===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:o,onChange:l=>a(l.target.value),className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(s.id),disabled:!o||r,className:i.primaryBtn,children:"Save"}),e.jsx("button",{onClick:m,disabled:r,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[#444444]",children:s.note}),s.reviewNote&&e.jsx("p",{className:"text-xs text-[#9c9890] italic mt-0.5",children:s.reviewNote}),e.jsx("p",{className:"text-xs text-[#666666] mt-0.5",children:new Date(s.createdAt*1e3).toLocaleDateString()})]})}),n!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>x(s.id,s.note),className:i.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:h,className:i.dangerBtn,children:"Delete"})]})]})}function ge(){const s=p.useUtils(),{data:n,isLoading:o}=p.memory.list.useQuery(),{data:a}=p.provider.getRegisteredTypes.useQuery(),c=p.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),E(""),j("unified"),A(!1)}}),m=p.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),x=p.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,r]=g.useState(null),h=p.memory.optimize.useMutation({onSuccess:t=>{s.memory.list.invalidate(),r(t.stats)}}),[l,f]=g.useState(null),[v,N]=g.useState(""),[u,b]=g.useState(null),[S,A]=g.useState(!1),[k,j]=g.useState("unified"),[P,E]=g.useState("");function R(t,y){f(t),N(y)}async function z(t){await m.mutateAsync({id:t,note:v}),f(null),N("")}function F(){f(null),N("")}const O=[{value:"unified",label:"Unified"},...(a??[]).map(t=>({value:t.type,label:t.label}))],$=5;if(o)return e.jsx(T,{size:"lg",centered:!0});const M=new Map;if(n)for(const t of n){const y=M.get(t.toolName)??[];y.push(t),M.set(t.toolName,y)}const D={editingId:l,editNote:v,setEditNote:N,onUpdate:z,onCancelEdit:F,onStartEdit:R,onDelete:t=>b(t),updatePending:m.isPending,removePending:x.isPending};return e.jsxs("div",{className:"space-y-4",children:[S?e.jsxs("div",{className:i.settingsCard+" space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-[#666666] font-sans",children:"Provider"}),e.jsx("select",{value:k,onChange:t=>{j(t.target.value),t.target.blur()},className:"bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-8 text-sm text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans appearance-none bg-[length:16px_16px] bg-[right_8px_center] bg-no-repeat",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")`},children:O.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:i.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:P,onChange:t=>E(t.target.value),onKeyDown:t=>{t.key==="Enter"&&P.trim()&&!c.isPending&&c.mutate({toolName:k,note:P})},placeholder:"Reusable lesson or pattern...",className:i.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c.mutate({toolName:k,note:P}),disabled:!P.trim()||c.isPending,className:i.primaryBtn,children:c.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{A(!1),E(""),j("unified")},disabled:c.isPending,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>A(!0),className:i.secondaryBtn,children:"+ Add Memory"}),M.size===0&&e.jsx("div",{className:i.settingsCard,children:e.jsx("p",{className:"text-sm text-[#666666]",children:"No memories yet. The agent will save notes here as it learns from tool usage."})}),[...M.entries()].map(([t,y])=>{const C=y.length>$;return e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${i.badge} ${i.badgeVariants.info}`,children:t}),C&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[y.length," memories"]}),e.jsx("button",{onClick:()=>h.mutate({toolName:t}),disabled:h.isPending||y.length===0,className:`ml-auto ${i.outlineBtn}`,title:"Optimize memories with AI",children:h.isPending&&h.variables?.toolName===t?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${C?" max-h-64 overflow-y-auto":""}`,children:y.map(w=>e.jsx(pe,{memory:w,...D},w.id))})]},t)}),e.jsx(K,{open:u!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{u!==null&&x.mutate({id:u}),b(null)},onCancel:()=>b(null)}),e.jsx(K,{open:d!==null,title:"Optimization Complete",message:d&&e.jsxs("div",{className:"space-y-1.5 text-sm text-[#444444]",children:[e.jsxs("p",{children:["Kept: ",e.jsx("span",{className:"font-medium",children:d.kept})]}),e.jsxs("p",{children:["Updated: ",e.jsx("span",{className:"font-medium",children:d.updated})]}),e.jsxs("p",{children:["Deleted: ",e.jsx("span",{className:"font-medium",children:d.deleted})]})]}),confirmLabel:"OK",cancelLabel:null,confirmStyle:"primary",onConfirm:()=>r(null),onCancel:()=>r(null)})]})}const G=["Pacific/Auckland","Australia/Sydney","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Berlin","UTC","Europe/London","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Pacific/Honolulu"];function V(s){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"",o=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"";return`${n} (${o})`}catch{return s}}const he=new Map(G.map(s=>[s,V(s)]));function fe(){const s=p.useUtils(),{data:n,isLoading:o}=p.settings.getAgentConfig.useQuery(),a=p.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),b(!1)}}),[c,m]=g.useState(""),[x,d]=g.useState(100),[r,h]=g.useState(50),[l,f]=g.useState(1024),[v,N]=g.useState(1e4),[u,b]=g.useState(!1);if(g.useEffect(()=>{n&&(m(n.timezone),d(n.directModeMaxSteps),h(n.subAgentMaxSteps),f(n.thinkingBudgetGoogle),N(n.thinkingBudgetAnthropic),b(!1))},[n]),o||!n)return null;const S=u&&(c!==n.timezone||x!==n.directModeMaxSteps||r!==n.subAgentMaxSteps||l!==n.thinkingBudgetGoogle||v!==n.thinkingBudgetAnthropic);function A(){a.mutate({timezone:c,directModeMaxSteps:x,subAgentMaxSteps:r,thinkingBudgetGoogle:l,thinkingBudgetAnthropic:v})}function k(){b(!0)}return e.jsx("div",{className:"max-w-lg",children:e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Timezone"}),e.jsxs("select",{value:c,onChange:j=>{m(j.target.value),k()},className:"appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans",children:[G.map(j=>e.jsx("option",{value:j,children:he.get(j)??j},j)),!G.includes(c)&&e.jsx("option",{value:c,children:V(c)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Direct mode max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:x,onChange:j=>{d(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Sub-agent max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:r,onChange:j=>{h(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Google thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:256,value:l,onChange:j=>{f(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Anthropic thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:1e3,value:v,onChange:j=>{N(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-3 border-t border-[#e8e6e1]",children:[e.jsx("button",{onClick:A,disabled:!S||a.isPending,className:i.primaryBtn,children:a.isPending?"Saving...":"Save"}),a.isSuccess&&!u&&e.jsx("span",{className:i.successText,children:"Saved"})]})]})})}function be(){return e.jsxs("div",{className:i.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"LLM API Keys"}),e.jsx(ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Data Providers"}),e.jsx(xe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Configuration"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Memory"}),e.jsx(ge,{})]})]})}export{be as Settings};
|
|
1
|
+
import{t as p,r as g,j as e,S as T,c as _,b as i,C as K,A as B,u as ee,d as se,W as q,M as te}from"./index-XO-cs6YP.js";import{S as ne}from"./SearchableSelect-DwcqGvga.js";function Z({type:s,label:n}){const o=p.useUtils(),{data:a,isLoading:c}=p.settings.getApiKey.useQuery(s),m=p.settings.saveApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),x=p.settings.removeApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),[d,r]=g.useState(!1),[h,l]=g.useState(""),[f,v]=g.useState(!1);async function N(){await m.mutateAsync({type:s,apiKey:h}),l(""),r(!1)}async function u(){await x.mutateAsync(s),r(!1),v(!1)}return c?e.jsx("div",{className:"px-4 py-3",children:e.jsx(T,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium w-24 shrink-0",children:n}),e.jsx("span",{className:i.maskedKey+" flex-1 truncate",style:a?{color:_.success}:void 0,children:a?a.maskedApiKey:"Not configured"}),!d&&e.jsx("button",{onClick:()=>{l(""),r(!0)},className:i.secondaryBtn+" text-xs px-3 py-1",children:a?"Edit":"Add"})]}),d&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[e.jsx("input",{type:h?"password":"text",value:h,onChange:b=>l(b.target.value),placeholder:a?.maskedApiKey??"Enter API key",className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:N,disabled:!h||m.isPending,className:i.primaryBtn+" text-xs px-3 py-1",children:m.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:m.isPending,className:i.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),a&&e.jsx("button",{onClick:()=>v(!0),disabled:x.isPending,className:i.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(K,{open:f,title:"Remove API key",message:`Remove the ${n} API key?`,confirmLabel:"Remove",onConfirm:u,onCancel:()=>v(!1)})]})}function ie({configuredProviders:s}){return e.jsx("div",{className:"border-t border-[#e8e6e1]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:i.tableHeaderRow,children:[e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:B.map(n=>{const o=s.has(n.provider);return e.jsxs("tr",{style:o?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:n.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:n.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.outputPrice.toFixed(2)]})]},n.modelId)})})]})})}function ae(){const[s,n]=g.useState(!1),o=ee();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"max-w-lg bg-white border border-[#d4d2cd] rounded divide-y divide-[#e8e6e1] overflow-hidden",children:[e.jsx(Z,{type:"anthropic",label:"Anthropic"}),e.jsx(Z,{type:"google",label:"Google AI"})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center justify-between px-4 py-3 text-sm text-[#666666] hover:bg-[#f5f4f0] transition-colors font-sans",children:[e.jsx("span",{className:"font-medium",children:"Model Pricing"}),e.jsx("span",{className:"text-xs transition-transform duration-200",style:{transform:s?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),s&&e.jsx(ie,{configuredProviders:o})]})]})}function oe({status:s,label:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${i.statusDot[s]}`}),n&&e.jsx("span",{className:i.statusLabel,children:n})]})}const U=`${B[1]?.provider??B[0].provider}:${B[1]?.modelId??B[0].modelId}`;function le({providerType:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.settings.getSubAgentModel.useQuery(s),c=p.settings.saveSubAgentModel.useMutation({onSuccess:()=>n.settings.getSubAgentModel.invalidate(s)}),m=se(),x=o?`${o.provider}:${o.modelId}`:U,d=m.some(l=>`${l.provider}:${l.modelId}`===x),r=d?x:`${m[0].provider}:${m[0].modelId}`;if(g.useEffect(()=>{!a&&o&&!d&&c.mutate({providerType:s,model:null})},[a,d]),a)return null;function h(l){if(l===U&&!o)return;const f=m.find(v=>`${v.provider}:${v.modelId}`===l);f&&(l===U?c.mutate({providerType:s,model:null}):c.mutate({providerType:s,model:{provider:f.provider,modelId:f.modelId}}))}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Model"}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("select",{value:r,onChange:l=>h(l.target.value),disabled:c.isPending,className:"w-full appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-7 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans disabled:opacity-50 disabled:cursor-not-allowed",children:m.map(l=>e.jsx("option",{value:`${l.provider}:${l.modelId}`,children:l.modelId},`${l.provider}:${l.modelId}`))}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]})}function re({existingConfig:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.provider.listGcpProjects.useQuery(void 0,{staleTime:q.updateCheckStaleTimeMs}),c=p.provider.saveConfig.useMutation({onSuccess:()=>{n.provider.getConfigs.invalidate(),n.provider.list.invalidate()}}),m=g.useMemo(()=>(o??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[o]),x=s.projectId??"";function d(r){r!==x&&c.mutate({type:"gcp",config:{...s,projectId:r}})}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(ne,{options:m,value:x,onChange:d,placeholder:a?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:a||c.isPending})})]})}function ce({checked:s,onChange:n,disabled:o,"aria-label":a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:o,onClick:()=>n(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${o?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s?"translate-x-[18px]":"translate-x-[3px]"}`})})}function de({type:s,label:n,connected:o,configured:a,onConfigure:c,onToggle:m,togglePending:x,toggleError:d,pingError:r,hasConfigFields:h,existingConfig:l}){const f=a||o;return e.jsxs("div",{className:i.settingsCard+" w-80",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{checked:a,onChange:v=>{v&&h?c():m(v)},disabled:x}),e.jsx("span",{className:"font-medium",children:n}),f?e.jsx(oe,{status:o?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${i.secondaryBtn} ${a&&h?"":"invisible"}`,children:"Edit"})]}),f&&e.jsx(le,{providerType:s}),f&&s==="gcp"&&l&&e.jsx(re,{existingConfig:l}),r&&!o&&e.jsx("p",{className:i.warnText+" mt-2",children:r}),d&&e.jsx("p",{className:i.errorText+" mt-2",children:d})]})}function H(s,n){return!!s&&!!n&&s===n}function ue({open:s,label:n,configFields:o,formValues:a,onFormChange:c,existingConfig:m,saveResult:x,savePending:d,configured:r,onSave:h,onClose:l,onRemove:f}){const v=o.some(u=>u.required!==!1&&u.type==="password"&&H(a[u.key],m?.[u.key])),N=o.some(u=>u.required!==!1&&!a[u.key]);return e.jsxs(te,{open:s,onClose:l,children:[e.jsxs("div",{className:i.dialogTitle+" text-base mb-4",children:["Configure ",n]}),e.jsx("div",{className:"space-y-3",children:o.map(u=>{const b=u.type==="password"&&H(a[u.key],m?.[u.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:i.sectionTitle,children:[u.label,u.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:u.type==="password"&&a[u.key]&&!b?"password":"text",value:a[u.key]??"",onChange:S=>c(u.key,S.target.value),onFocus:S=>{b&&S.target.select()},placeholder:`Enter ${u.label.toLowerCase()}`,className:`${i.input} ${b?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},u.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:h,disabled:N||v||d,className:i.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:l,disabled:d,className:i.secondaryBtn,children:"Cancel"}),r&&e.jsx("button",{onClick:f,disabled:d,className:i.dangerBtn,children:"Remove"})]}),v&&!d&&!x&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),x&&e.jsx("div",{className:`mt-3 ${x.success?i.successText:i.errorText}`,children:x.success?"Connected successfully":x.error||"Connection failed"})]})}function me(s,n){const o={};for(const a of s)o[a.key]=n?.[a.key]??"";return o}function xe(){const s=p.useUtils(),{data:n,isLoading:o}=p.provider.list.useQuery(),{data:a,isLoading:c}=p.provider.getConfigs.useQuery(),{data:m,isLoading:x}=p.provider.getRegisteredTypes.useQuery(),{data:d}=p.provider.ping.useQuery(void 0,{staleTime:q.sessionStaleTimeMs,refetchOnMount:"always"}),r=p.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),h=p.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[l,f]=g.useState(null),[v,N]=g.useState({}),[u,b]=g.useState(null),[S,A]=g.useState(null),[k,j]=g.useState({});function P(t){const y=a?.find(w=>w.type===t),C=m?.find(w=>w.type===t);N(me(C?.configFields??[],y?.config)),b(null),f(t)}function E(){f(null),N({}),b(null)}async function R(t){b(null);try{const y=await r.mutateAsync({type:t,config:v});b(y),y.success&&(f(null),N({}))}catch{b({success:!1,error:"Failed to save configuration"})}}async function z(t,y){if(y){j(C=>{const w={...C};return delete w[t],w});try{const C=await r.mutateAsync({type:t,config:{}});C.success||j(w=>({...w,[t]:C.error??"Connection failed"}))}catch{j(C=>({...C,[t]:"Failed to save configuration"}))}}else A(t)}async function F(t){await h.mutateAsync(t),f(null),N({}),b(null),A(null)}const O=o||c||x,$=m??[];if(O)return e.jsx(T,{size:"lg",centered:!0});const M=l?$.find(t=>t.type===l):null,D=l?a?.find(t=>t.type===l):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:$.map(({type:t,label:y,configFields:C})=>{const w=n?.find(I=>I.type===t),Q=a?.find(I=>I.type===t),W=!!Q,L=d?.find(I=>I.type===t),Y=L?L.ok:!!w?.connected,J=C.length>0,X=L&&!L.ok?L.error:void 0;return e.jsx(de,{type:t,label:y,connected:Y,configured:W,onConfigure:()=>P(t),onToggle:I=>z(t,I),togglePending:r.isPending||h.isPending,toggleError:k[t],pingError:X,hasConfigFields:J,existingConfig:Q?.config},t)})}),l&&M&&e.jsx(ue,{open:!0,label:M.label,configFields:M.configFields,formValues:v,onFormChange:(t,y)=>N(C=>({...C,[t]:y})),existingConfig:D?.config??null,saveResult:u,savePending:r.isPending,configured:!!D,onSave:()=>R(l),onClose:E,onRemove:()=>A(l)}),e.jsx(K,{open:S!==null,title:"Disable provider",message:`Disable ${$.find(t=>t.type===S)?.label??S}?`,confirmLabel:"Disable",onConfirm:()=>{S&&F(S)},onCancel:()=>A(null)})]})}function pe({memory:s,editingId:n,editNote:o,setEditNote:a,onUpdate:c,onCancelEdit:m,onStartEdit:x,onDelete:d,updatePending:r,removePending:h}){return e.jsxs("li",{className:"flex items-start justify-between gap-3 py-1.5 border-b border-[#d4d2cd] last:border-b-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:n===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:o,onChange:l=>a(l.target.value),className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(s.id),disabled:!o||r,className:i.primaryBtn,children:"Save"}),e.jsx("button",{onClick:m,disabled:r,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[#444444]",children:s.note}),s.reviewNote&&e.jsx("p",{className:"text-xs text-[#9c9890] italic mt-0.5",children:s.reviewNote}),e.jsx("p",{className:"text-xs text-[#666666] mt-0.5",children:new Date(s.createdAt*1e3).toLocaleDateString()})]})}),n!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>x(s.id,s.note),className:i.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:h,className:i.dangerBtn,children:"Delete"})]})]})}function ge(){const s=p.useUtils(),{data:n,isLoading:o}=p.memory.list.useQuery(),{data:a}=p.provider.getRegisteredTypes.useQuery(),c=p.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),E(""),j("unified"),A(!1)}}),m=p.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),x=p.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,r]=g.useState(null),h=p.memory.optimize.useMutation({onSuccess:t=>{s.memory.list.invalidate(),r(t.stats)}}),[l,f]=g.useState(null),[v,N]=g.useState(""),[u,b]=g.useState(null),[S,A]=g.useState(!1),[k,j]=g.useState("unified"),[P,E]=g.useState("");function R(t,y){f(t),N(y)}async function z(t){await m.mutateAsync({id:t,note:v}),f(null),N("")}function F(){f(null),N("")}const O=[{value:"unified",label:"Unified"},...(a??[]).map(t=>({value:t.type,label:t.label}))],$=5;if(o)return e.jsx(T,{size:"lg",centered:!0});const M=new Map;if(n)for(const t of n){const y=M.get(t.toolName)??[];y.push(t),M.set(t.toolName,y)}const D={editingId:l,editNote:v,setEditNote:N,onUpdate:z,onCancelEdit:F,onStartEdit:R,onDelete:t=>b(t),updatePending:m.isPending,removePending:x.isPending};return e.jsxs("div",{className:"space-y-4",children:[S?e.jsxs("div",{className:i.settingsCard+" space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-[#666666] font-sans",children:"Provider"}),e.jsx("select",{value:k,onChange:t=>{j(t.target.value),t.target.blur()},className:"bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-8 text-sm text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans appearance-none bg-[length:16px_16px] bg-[right_8px_center] bg-no-repeat",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")`},children:O.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:i.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:P,onChange:t=>E(t.target.value),onKeyDown:t=>{t.key==="Enter"&&P.trim()&&!c.isPending&&c.mutate({toolName:k,note:P})},placeholder:"Reusable lesson or pattern...",className:i.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c.mutate({toolName:k,note:P}),disabled:!P.trim()||c.isPending,className:i.primaryBtn,children:c.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{A(!1),E(""),j("unified")},disabled:c.isPending,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>A(!0),className:i.secondaryBtn,children:"+ Add Memory"}),M.size===0&&e.jsx("div",{className:i.settingsCard,children:e.jsx("p",{className:"text-sm text-[#666666]",children:"No memories yet. The agent will save notes here as it learns from tool usage."})}),[...M.entries()].map(([t,y])=>{const C=y.length>$;return e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${i.badge} ${i.badgeVariants.info}`,children:t}),C&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[y.length," memories"]}),e.jsx("button",{onClick:()=>h.mutate({toolName:t}),disabled:h.isPending||y.length===0,className:`ml-auto ${i.outlineBtn}`,title:"Optimize memories with AI",children:h.isPending&&h.variables?.toolName===t?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${C?" max-h-64 overflow-y-auto":""}`,children:y.map(w=>e.jsx(pe,{memory:w,...D},w.id))})]},t)}),e.jsx(K,{open:u!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{u!==null&&x.mutate({id:u}),b(null)},onCancel:()=>b(null)}),e.jsx(K,{open:d!==null,title:"Optimization Complete",message:d&&e.jsxs("div",{className:"space-y-1.5 text-sm text-[#444444]",children:[e.jsxs("p",{children:["Kept: ",e.jsx("span",{className:"font-medium",children:d.kept})]}),e.jsxs("p",{children:["Updated: ",e.jsx("span",{className:"font-medium",children:d.updated})]}),e.jsxs("p",{children:["Deleted: ",e.jsx("span",{className:"font-medium",children:d.deleted})]})]}),confirmLabel:"OK",cancelLabel:null,confirmStyle:"primary",onConfirm:()=>r(null),onCancel:()=>r(null)})]})}const G=["Pacific/Auckland","Australia/Sydney","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Berlin","UTC","Europe/London","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Pacific/Honolulu"];function V(s){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"",o=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"";return`${n} (${o})`}catch{return s}}const he=new Map(G.map(s=>[s,V(s)]));function fe(){const s=p.useUtils(),{data:n,isLoading:o}=p.settings.getAgentConfig.useQuery(),a=p.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),b(!1)}}),[c,m]=g.useState(""),[x,d]=g.useState(100),[r,h]=g.useState(50),[l,f]=g.useState(1024),[v,N]=g.useState(1e4),[u,b]=g.useState(!1);if(g.useEffect(()=>{n&&(m(n.timezone),d(n.directModeMaxSteps),h(n.subAgentMaxSteps),f(n.thinkingBudgetGoogle),N(n.thinkingBudgetAnthropic),b(!1))},[n]),o||!n)return null;const S=u&&(c!==n.timezone||x!==n.directModeMaxSteps||r!==n.subAgentMaxSteps||l!==n.thinkingBudgetGoogle||v!==n.thinkingBudgetAnthropic);function A(){a.mutate({timezone:c,directModeMaxSteps:x,subAgentMaxSteps:r,thinkingBudgetGoogle:l,thinkingBudgetAnthropic:v})}function k(){b(!0)}return e.jsx("div",{className:"max-w-lg",children:e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Timezone"}),e.jsxs("select",{value:c,onChange:j=>{m(j.target.value),k()},className:"appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans",children:[G.map(j=>e.jsx("option",{value:j,children:he.get(j)??j},j)),!G.includes(c)&&e.jsx("option",{value:c,children:V(c)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Direct mode max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:x,onChange:j=>{d(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Sub-agent max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:r,onChange:j=>{h(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Google thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:256,value:l,onChange:j=>{f(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Anthropic thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:1e3,value:v,onChange:j=>{N(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-3 border-t border-[#e8e6e1]",children:[e.jsx("button",{onClick:A,disabled:!S||a.isPending,className:i.primaryBtn,children:a.isPending?"Saving...":"Save"}),a.isSuccess&&!u&&e.jsx("span",{className:i.successText,children:"Saved"})]})]})})}function be(){return e.jsxs("div",{className:i.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"LLM API Keys"}),e.jsx(ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Data Providers"}),e.jsx(xe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Configuration"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Memory"}),e.jsx(ge,{})]})]})}export{be as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-
|
|
1
|
+
import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-mO3J4JDi.js";import{r,j as f}from"./index-XO-cs6YP.js";import"./SearchableSelect-DwcqGvga.js";var j=({code:i,language:e,raw:t,className:m,startLine:u,lineNumbers:n,...g})=>{let{shikiTheme:o}=r.useContext(p),a=x(),[h,s]=r.useState(t);return r.useEffect(()=>{if(!a){s(t);return}let l=a.highlight({code:i,language:e,themes:o},c=>{s(c)});l&&s(l)},[i,e,o,a,t]),f.jsx(d,{className:m,language:e,lineNumbers:n,result:h,startLine:u,...g})};export{j as HighlightedCodeBlockBody};
|