@tianshu-ai/tianshu 0.138.0 → 0.138.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/packages/server/dist/chat/tool-loop-detector.d.ts +1 -8
- package/packages/server/dist/chat/tool-loop-detector.d.ts.map +1 -1
- package/packages/server/dist/chat/tool-loop-detector.js +19 -55
- package/packages/server/dist/chat/tool-loop-detector.js.map +1 -1
- package/packages/web/dist/assets/{DataSourceConfigForm-C31w8R30.js → DataSourceConfigForm-BeXYPPY0.js} +1 -1
- package/packages/web/dist/assets/{bundle-web-B9fPXwaJ.js → bundle-web-ktSi9xR0.js} +1 -1
- package/packages/web/dist/assets/{index-C58UxzcE.js → index-CQxDTKff.js} +4 -4
- package/packages/web/dist/assets/{react-force-graph-2d-BUmpTEeP.js → react-force-graph-2d-HrH9lH-G.js} +1 -1
- package/packages/web/dist/index.html +1 -1
- package/scripts/patch-openai-sdk.js +95 -0
- package/scripts/postinstall.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tianshu-ai/tianshu",
|
|
3
|
-
"version": "0.138.
|
|
3
|
+
"version": "0.138.2",
|
|
4
4
|
"description": "An open AI agent platform with a sidecar browser. Built in public.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/tianshu-ai/tianshu",
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"plugins/**/agent-seeds/**",
|
|
34
34
|
"plugins/**/templates/**",
|
|
35
35
|
"plugins/**/sandbox-image/**",
|
|
36
|
+
"scripts/postinstall.js",
|
|
37
|
+
"scripts/patch-openai-sdk.js",
|
|
36
38
|
"scripts/qwen3-tts-server/**",
|
|
37
39
|
"scripts/QWEN3_TTS_SETUP.md",
|
|
38
40
|
"README.md",
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
"setup": "node bin/tianshu.mjs setup",
|
|
58
60
|
"prepublishOnly": "npm run build",
|
|
59
61
|
"serve": "node bin/serve.mjs",
|
|
60
|
-
"postinstall": "node scripts/
|
|
62
|
+
"postinstall": "node scripts/postinstall.js"
|
|
61
63
|
},
|
|
62
64
|
"publishConfig": {
|
|
63
65
|
"access": "public",
|
|
@@ -16,13 +16,6 @@ export declare class ToolLoopDetector {
|
|
|
16
16
|
* the exact-streak detector misses them.
|
|
17
17
|
*/
|
|
18
18
|
private seen;
|
|
19
|
-
/**
|
|
20
|
-
* Tracks (tool name → output hash → count). Catches cases where
|
|
21
|
-
* the model calls the same tool with different arguments but gets
|
|
22
|
-
* the same result back — the information is already in context
|
|
23
|
-
* regardless of how the query was phrased.
|
|
24
|
-
*/
|
|
25
|
-
private toolOutputSeen;
|
|
26
19
|
/** Tracks total calls per tool name across the session. */
|
|
27
20
|
private toolFreq;
|
|
28
21
|
get endReason(): string | null;
|
|
@@ -32,7 +25,7 @@ export declare class ToolLoopDetector {
|
|
|
32
25
|
/** Full reset — clears everything including cross-turn duplicate tracking. */
|
|
33
26
|
reset(): void;
|
|
34
27
|
/** Reset per-turn state. Keeps cross-turn duplicate tracking
|
|
35
|
-
* (seen
|
|
28
|
+
* (seen) but resets everything else so detection
|
|
36
29
|
* thresholds start fresh each turn. */
|
|
37
30
|
resetStreaks(): void;
|
|
38
31
|
/** Register tool schemas so fingerprinting only uses declared parameters. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-loop-detector.d.ts","sourceRoot":"","sources":["../../src/chat/tool-loop-detector.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"tool-loop-detector.d.ts","sourceRoot":"","sources":["../../src/chat/tool-loop-detector.ts"],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AE;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;4DACoD;QACpD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KAC5D,SAEoB;QAAE,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE;YAAE,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,CAAA;KAAE;;;kBAA5B,MAAM;mBAAS,MAAM;;;;;;;;mBAmCvH;IAED,yCAAyC;IACzC,cAAc,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC;gBAQoB,KAAK;mBAEzB;CACF"}
|
|
@@ -9,7 +9,6 @@ import { createLogger } from "../setup/logger.js";
|
|
|
9
9
|
const log = createLogger("loop-detect");
|
|
10
10
|
// Thresholds (exact / name-only):
|
|
11
11
|
// hint: 3 / 5 warn: 5 / 8 stop: 10 / 15
|
|
12
|
-
const EXACT_HINT = 3, EXACT_WARN = 5, EXACT_STOP = 10;
|
|
13
12
|
// Cycle detection thresholds: how many full repeats of a pattern
|
|
14
13
|
// before we hint / warn / stop. E.g. A B C A B C A B C = 3 repeats
|
|
15
14
|
// of cycle length 3.
|
|
@@ -19,11 +18,11 @@ const MAX_CYCLE_LEN = 8;
|
|
|
19
18
|
// Duplicate call detection: same input → same output.
|
|
20
19
|
// If we've seen this exact (tool, args) before AND got the same result,
|
|
21
20
|
// there's no point calling it again — the answer is already in context.
|
|
22
|
-
const DUP_HINT =
|
|
21
|
+
const DUP_HINT = 5, DUP_WARN = 8, DUP_STOP = 12;
|
|
23
22
|
// Tool name frequency: same tool called too many times (any args).
|
|
24
23
|
// Catches loops where the model varies arguments but keeps hammering
|
|
25
24
|
// the same tool (e.g. bridge_exec with sleep 1, sleep 2, sleep 3, repeat).
|
|
26
|
-
const TOOL_FREQ_HINT =
|
|
25
|
+
const TOOL_FREQ_HINT = 30, TOOL_FREQ_WARN = 50, TOOL_FREQ_STOP = 100;
|
|
27
26
|
export class ToolLoopDetector {
|
|
28
27
|
calls = [];
|
|
29
28
|
_endReason = null;
|
|
@@ -37,13 +36,6 @@ export class ToolLoopDetector {
|
|
|
37
36
|
* the exact-streak detector misses them.
|
|
38
37
|
*/
|
|
39
38
|
seen = new Map();
|
|
40
|
-
/**
|
|
41
|
-
* Tracks (tool name → output hash → count). Catches cases where
|
|
42
|
-
* the model calls the same tool with different arguments but gets
|
|
43
|
-
* the same result back — the information is already in context
|
|
44
|
-
* regardless of how the query was phrased.
|
|
45
|
-
*/
|
|
46
|
-
toolOutputSeen = new Map();
|
|
47
39
|
/** Tracks total calls per tool name across the session. */
|
|
48
40
|
toolFreq = new Map();
|
|
49
41
|
get endReason() { return this._endReason; }
|
|
@@ -51,9 +43,9 @@ export class ToolLoopDetector {
|
|
|
51
43
|
get wasTriggered() { return this._wasTriggered; }
|
|
52
44
|
clearEndReason() { this._endReason = null; }
|
|
53
45
|
/** Full reset — clears everything including cross-turn duplicate tracking. */
|
|
54
|
-
reset() { this.calls.length = 0; this._endReason = null; this._wasTriggered = false; this.seen.clear(); this.
|
|
46
|
+
reset() { this.calls.length = 0; this._endReason = null; this._wasTriggered = false; this.seen.clear(); this.toolFreq.clear(); }
|
|
55
47
|
/** Reset per-turn state. Keeps cross-turn duplicate tracking
|
|
56
|
-
* (seen
|
|
48
|
+
* (seen) but resets everything else so detection
|
|
57
49
|
* thresholds start fresh each turn. */
|
|
58
50
|
resetStreaks() {
|
|
59
51
|
this.calls.length = 0;
|
|
@@ -78,6 +70,11 @@ export class ToolLoopDetector {
|
|
|
78
70
|
if (validKeys) {
|
|
79
71
|
filtered = {};
|
|
80
72
|
for (const k of validKeys) {
|
|
73
|
+
// Skip _-prefixed keys even if they are in the schema.
|
|
74
|
+
// _title is injected by tianshu for UI display and varies
|
|
75
|
+
// per call; including it makes every fingerprint unique.
|
|
76
|
+
if (k.startsWith("_"))
|
|
77
|
+
continue;
|
|
81
78
|
if (k in raw)
|
|
82
79
|
filtered[k] = raw[k];
|
|
83
80
|
}
|
|
@@ -102,23 +99,6 @@ export class ToolLoopDetector {
|
|
|
102
99
|
const maxHistory = MAX_CYCLE_LEN * (CYCLE_STOP_REPEATS + 1) + 2;
|
|
103
100
|
if (this.calls.length > maxHistory)
|
|
104
101
|
this.calls.splice(0, this.calls.length - maxHistory);
|
|
105
|
-
let exactStreak = 0;
|
|
106
|
-
for (let i = this.calls.length - 1; i >= 0; i--) {
|
|
107
|
-
if (this.calls[i].fp === fp)
|
|
108
|
-
exactStreak++;
|
|
109
|
-
else
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
// Only detect exact match loops (same tool + same args).
|
|
113
|
-
// Name-only detection (same tool, different args) removed —
|
|
114
|
-
// it false-positives on legitimate exploration like querying
|
|
115
|
-
// different tables with ds_query.
|
|
116
|
-
if (exactStreak >= EXACT_STOP)
|
|
117
|
-
return { action: "stop", message: `Repetitive tool call loop detected: ${name} was called ${exactStreak} times with identical arguments. The result is the same every time. Do NOT call this tool again. Respond to the user or try a completely different approach.` };
|
|
118
|
-
if (exactStreak >= EXACT_WARN)
|
|
119
|
-
return { action: "warn", message: `Warning: ${name} was called ${exactStreak} times with identical arguments. The result is the same every time. Stop repeating this call and try a different approach.` };
|
|
120
|
-
if (exactStreak >= EXACT_HINT)
|
|
121
|
-
return { action: "hint", message: `Note: ${name} was called ${exactStreak} times with identical arguments. Consider whether continuing is productive, or try a different approach.` };
|
|
122
102
|
// ── Cycle / pattern detection ────────────────────────────────
|
|
123
103
|
// Detect repeating patterns like A B C A B C A B C.
|
|
124
104
|
// Check cycle lengths from 2..MAX_CYCLE_LEN.
|
|
@@ -126,11 +106,11 @@ export class ToolLoopDetector {
|
|
|
126
106
|
if (cycle) {
|
|
127
107
|
const tools = cycle.pattern.map(c => c.split("::")[0]).join(" → ");
|
|
128
108
|
if (cycle.repeats >= CYCLE_STOP_REPEATS)
|
|
129
|
-
return { action: "stop", message: `
|
|
109
|
+
return { action: "stop", message: `The pattern [${tools}] has repeated ${cycle.repeats} times. Please review: if this is a loop, try a different approach to break out; if not, continue.` };
|
|
130
110
|
if (cycle.repeats >= CYCLE_WARN_REPEATS)
|
|
131
|
-
return { action: "warn", message: `
|
|
111
|
+
return { action: "warn", message: `The pattern [${tools}] has repeated ${cycle.repeats} times. Please check whether you are in a loop. If yes, try an alternative approach; if not, continue.` };
|
|
132
112
|
if (cycle.repeats >= CYCLE_HINT_REPEATS)
|
|
133
|
-
return { action: "hint", message: `
|
|
113
|
+
return { action: "hint", message: `The pattern [${tools}] has repeated ${cycle.repeats} times. Quick self-check: is this a loop? If yes, try a different approach; if not, carry on.` };
|
|
134
114
|
}
|
|
135
115
|
return { action: "ok" };
|
|
136
116
|
}
|
|
@@ -197,42 +177,26 @@ export class ToolLoopDetector {
|
|
|
197
177
|
if (prev && prev.outputHash === outputHash) {
|
|
198
178
|
prev.count++;
|
|
199
179
|
if (prev.count >= DUP_STOP)
|
|
200
|
-
return { action: "stop", message:
|
|
180
|
+
return { action: "stop", message: `${name} has been called ${prev.count} times with the same arguments and returned the same result. The data is already in the conversation. Please review: if this is a loop, try a different approach; if you need the data, it is already available above.` };
|
|
201
181
|
if (prev.count >= DUP_WARN)
|
|
202
|
-
return { action: "warn", message:
|
|
182
|
+
return { action: "warn", message: `${name} returned the same result ${prev.count} times for the same arguments. Please check whether you are in a loop. The data is already in the conversation; if you need it, look above instead of re-querying.` };
|
|
203
183
|
if (prev.count >= DUP_HINT)
|
|
204
|
-
return { action: "hint", message:
|
|
184
|
+
return { action: "hint", message: `${name} returned the same result again (${prev.count} times). Quick self-check: the data is already in the conversation. If this is a loop, try a different approach; if not, carry on.` };
|
|
205
185
|
}
|
|
206
186
|
else {
|
|
207
187
|
this.seen.set(fp, { outputHash, count: 1 });
|
|
208
188
|
}
|
|
209
|
-
// 2.
|
|
210
|
-
// The model may rephrase the query but the underlying data
|
|
211
|
-
// hasn't changed — the result is identical and already in context.
|
|
212
|
-
let toolOutputs = this.toolOutputSeen.get(name);
|
|
213
|
-
if (!toolOutputs) {
|
|
214
|
-
toolOutputs = new Map();
|
|
215
|
-
this.toolOutputSeen.set(name, toolOutputs);
|
|
216
|
-
}
|
|
217
|
-
const outputCount = (toolOutputs.get(outputHash) ?? 0) + 1;
|
|
218
|
-
toolOutputs.set(outputHash, outputCount);
|
|
219
|
-
if (outputCount >= DUP_STOP)
|
|
220
|
-
return { action: "stop", message: `Redundant tool call: ${name} has returned the same result ${outputCount} times (with different arguments each time). The information is already in the conversation. Do NOT call ${name} again for this data. Respond to the user or try a completely different approach.` };
|
|
221
|
-
if (outputCount >= DUP_WARN)
|
|
222
|
-
return { action: "warn", message: `Warning: ${name} has returned the same result ${outputCount} times despite different arguments. The data is already available. Stop querying for the same information.` };
|
|
223
|
-
if (outputCount >= DUP_HINT)
|
|
224
|
-
return { action: "hint", message: `Note: ${name} returned the same result again (${outputCount} times, different args). The information is already in the conversation.` };
|
|
225
|
-
// 3. Tool name frequency: same tool called too many times regardless
|
|
189
|
+
// 2. Tool name frequency: same tool called too many times regardless
|
|
226
190
|
// of arguments or results. Catches loops where the model keeps
|
|
227
191
|
// hammering a tool with varied args (e.g. sleep 1, sleep 2, sleep 3, repeat).
|
|
228
192
|
const freq = (this.toolFreq.get(name) ?? 0) + 1;
|
|
229
193
|
this.toolFreq.set(name, freq);
|
|
230
194
|
if (freq >= TOOL_FREQ_STOP)
|
|
231
|
-
return { action: "stop", message: `${name} has been called ${freq} times
|
|
195
|
+
return { action: "stop", message: `${name} has been called ${freq} times this turn. Please review: if this is a loop, try a different approach to break out; if not, continue.` };
|
|
232
196
|
if (freq >= TOOL_FREQ_WARN)
|
|
233
|
-
return { action: "warn", message:
|
|
197
|
+
return { action: "warn", message: `${name} has been called ${freq} times this turn. Please check whether you are in a loop. If yes, try an alternative approach; if not, continue.` };
|
|
234
198
|
if (freq >= TOOL_FREQ_HINT)
|
|
235
|
-
return { action: "hint", message:
|
|
199
|
+
return { action: "hint", message: `${name} has been called ${freq} times this turn. Quick self-check: is this a loop? If yes, try a different approach; if not, carry on.` };
|
|
236
200
|
return { action: "ok" };
|
|
237
201
|
}
|
|
238
202
|
/** afterToolCall hook for pi-agent-core. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-loop-detector.js","sourceRoot":"","sources":["../../src/chat/tool-loop-detector.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,uBAAuB;AACvB,4DAA4D;AAC5D,mEAAmE;AACnE,EAAE;AACF,gEAAgE;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,GAAG,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AASxC,kCAAkC;AAClC,uDAAuD;AACvD,MAAM,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,EAAE,CAAC;AAEtD,iEAAiE;AACjE,mEAAmE;AACnE,qBAAqB;AACrB,MAAM,kBAAkB,GAAG,CAAC,EAAE,kBAAkB,GAAG,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC;AAC7E,oEAAoE;AACpE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,sDAAsD;AACtD,wEAAwE;AACxE,wEAAwE;AACxE,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;AAE/C,mEAAmE;AACnE,qEAAqE;AACrE,2EAA2E;AAC3E,MAAM,cAAc,GAAG,CAAC,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,GAAG,EAAE,CAAC;AAElE,MAAM,OAAO,gBAAgB;IACnB,KAAK,GAAwC,EAAE,CAAC;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AI,CAAC,IAAI,CAAC,UAAU;gBAAE,OAAO,SAAS,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IAAI,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,EAAE,MAAM,EAAE,KAAc,EAAE,CAAC;QACpC,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{C as t,E as n,O as r,S as i,T as a,_ as o,b as s,g as c,k as l,v as u,w as d,x as f,y as p}from"./index-C58UxzcE.js";var m=e(l(),1),h=o(),g=[{id:`neo4j`,name:`Neo4j`,fields:[{key:`uri`,label:`ds.field.uri`,placeholder:`bolt://localhost:7687`,required:!0},{key:`username`,label:`ds.field.username`,placeholder:`neo4j`,required:!0},{key:`password`,label:`ds.field.password`,secret:!0,required:!0},{key:`database`,label:`ds.field.database`,placeholder:`neo4j`}]},{id:`mysql`,name:`MySQL`,fields:[{key:`host`,label:`ds.field.host`,placeholder:`localhost`,required:!0},{key:`port`,label:`ds.field.port`,placeholder:`3306`},{key:`username`,label:`ds.field.username`,placeholder:`root`,required:!0},{key:`password`,label:`ds.field.password`,secret:!0,required:!0},{key:`database`,label:`ds.field.database`,required:!0}]},{id:`rest`,name:`REST API`,fields:[{key:`baseUrl`,label:`ds.field.baseUrl`,placeholder:`https://api.example.com`,required:!0},{key:`headers`,label:`ds.field.headers`,placeholder:`{"Authorization": "Bearer ***"}`},{key:`timeout`,label:`ds.field.timeout`,placeholder:`30000`}]}],_=`w-full rounded-md border border-border-default bg-bg-elevated px-3 py-1.5 text-xs text-fg-default outline-none placeholder:text-fg-fainter focus:border-brand-500`,v=`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors`,y=`${v} border-accent text-accent`,b=`${v} border-transparent text-fg-muted hover:text-fg-default`,x=`/api/p/datasource`;function S({plugin:e}){let t=c(),[n,r]=(0,m.useState)(`user`),[i,o]=(0,m.useState)(!1),[s,l]=(0,m.useState)(g);return(0,m.useEffect)(()=>{let t=e.config?.connections;t&&typeof t==`object`&&o(!0)},[e]),(0,m.useEffect)(()=>{fetch(`${x}/types`,{credentials:`include`}).then(e=>e.ok?e.json():null).then(e=>{e?.types?.length>0&&l(e.types)}).catch(()=>{})},[]),(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-0 border-b border-border-subtle`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>r(`user`),className:n===`user`?y:b,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(p,{size:12}),t(`ds.myConnections`)]})}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>r(`tenant`),className:n===`tenant`?y:b,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(a,{size:12}),t(`ds.tenantConnections`)]})})]}),n===`tenant`&&i?(0,h.jsx)(C,{plugin:e,types:s}):(0,h.jsx)(w,{types:s})]})}function C({plugin:e,types:t}){let i=c(),a=n(e=>e.setPlugins),[o,s]=(0,m.useState)({}),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(null),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)(!1),[S,C]=(0,m.useState)(``),[w,E]=(0,m.useState)(t[0]?.id??``);(0,m.useEffect)(()=>{let t=e.config?.connections;t&&typeof t==`object`&&s(t)},[e.config]);function D(e,t,n){s(r=>({...r,[e]:{...r[e],[t]:n}})),u(!0)}function O(e){s(t=>{let n={...t};return delete n[e],n}),u(!0)}function k(){let e=S.trim().replace(/[^a-zA-Z0-9_-]/g,`-`);e&&!o[e]&&(s(t=>({...t,[e]:{type:w,description:``}})),C(``),b(!1),u(!0))}async function A(){f(!0),g(null);try{let e=await r.setPluginConfig(`datasource`,{connections:o});a(e.plugins),u(!1)}catch(e){g(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function j(e){v(t=>({...t,[e]:{ok:!1,msg:i(`ds.testing`)}}));try{let t=await(await fetch(`${x}/test/${encodeURIComponent(e)}`,{method:`POST`,credentials:`include`})).json();v(n=>({...n,[e]:{ok:!!t.ok,msg:t.ok?i(`ds.connected`):t.error||i(`ds.failed`)}}))}catch(t){v(n=>({...n,[e]:{ok:!1,msg:t instanceof Error?t.message:String(t)}}))}}return(0,h.jsx)(T,{connections:o,types:t,scope:`tenant`,dirty:l,saving:d,error:p,testResults:_,adding:y,newName:S,newType:w,onUpdateField:D,onRemove:O,onAdd:k,onSave:A,onTest:j,onSetAdding:b,onSetNewName:C,onSetNewType:E})}function w({types:e}){let t=c(),[n,r]=(0,m.useState)({}),[a,o]=(0,m.useState)(!1),[s,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)({}),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(``),[b,S]=(0,m.useState)(e[0]?.id??``),[C,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>{fetch(`${x}/user-connections`,{credentials:`include`}).then(e=>e.ok?e.json():null).then(e=>{e?.connections&&r(e.connections),w(!0)}).catch(()=>w(!0))},[]);function E(e,t,n){r(r=>({...r,[e]:{...r[e],[t]:n}})),o(!0)}async function D(e){r(t=>{let n={...t};return delete n[e],n});try{let t=await(await fetch(`${x}/user-connections/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`})).json();t.ok||d(t.error||`Delete failed`)}catch(e){d(e instanceof Error?e.message:String(e))}}function O(){let e=v.trim().replace(/[^a-zA-Z0-9_-]/g,`-`);e&&!n[e]&&(r(t=>({...t,[e]:{type:b,description:``}})),y(``),_(!1),o(!0))}let k=(0,m.useCallback)(async()=>{l(!0),d(null);try{let e=await(await fetch(`${x}/user-connections`,{method:`PUT`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({connections:n})})).json();if(!e.ok)throw Error(e.error||`Save failed`);o(!1)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[n]);async function A(e){p(n=>({...n,[e]:{ok:!1,msg:t(`ds.testing`)}}));try{a&&await k();let n=await(await fetch(`${x}/test/${encodeURIComponent(e)}`,{method:`POST`,credentials:`include`})).json();p(r=>({...r,[e]:{ok:!!n.ok,msg:n.ok?t(`ds.connected`):n.error||t(`ds.failed`)}}))}catch(t){p(n=>({...n,[e]:{ok:!1,msg:t instanceof Error?t.message:String(t)}}))}}return C?(0,h.jsx)(T,{connections:n,types:e,scope:`user`,dirty:a,saving:s,error:u,testResults:f,adding:g,newName:v,newType:b,onUpdateField:E,onRemove:D,onAdd:O,onSave:k,onTest:A,onSetAdding:_,onSetNewName:y,onSetNewType:S}):(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-faint`,children:[(0,h.jsx)(i,{size:12,className:`animate-spin`}),` Loading…`]})}function T({connections:e,types:n,scope:r,dirty:a,saving:o,error:l,testResults:p,adding:m,newName:g,newType:v,onUpdateField:y,onRemove:b,onAdd:x,onSave:S,onTest:C,onSetAdding:w,onSetNewName:T,onSetNewType:E}){let D=c(),O=Object.keys(e);return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[r===`tenant`&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.tenantHint`)}),r===`user`&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.userHint`)}),O.length===0&&!m&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.noConnections`)}),O.map(r=>{let i=e[r],a=n.find(e=>e.id===i.type),o=p[r];return(0,h.jsxs)(`div`,{className:`rounded-lg border border-border-subtle p-3 space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-[13px] font-medium text-fg-default`,children:r}),(0,h.jsx)(`span`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-xs text-fg-faint`,children:i.type})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>C(r),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs text-fg-muted hover:bg-bg-raised`,title:D(`ds.testConnection`),children:[(0,h.jsx)(u,{size:12}),` `,D(`ds.test`)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>b(r),className:`rounded p-1 text-fg-faint hover:bg-bg-raised hover:text-danger`,children:(0,h.jsx)(s,{size:12})})]})]}),o&&(0,h.jsxs)(`div`,{className:`flex items-center gap-1 text-xs ${o.ok?`text-success`:`text-danger`}`,children:[o.ok?(0,h.jsx)(d,{size:12}):(0,h.jsx)(t,{size:12}),o.msg]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`mb-0.5 block text-xs text-fg-faint`,children:D(`ds.description`)}),(0,h.jsx)(`input`,{className:_,value:String(i.description??``),onChange:e=>y(r,`description`,e.target.value),placeholder:D(`ds.descriptionPlaceholder`),autoComplete:`off`})]}),a?.fields.map(e=>e.showWhen&&!Object.entries(e.showWhen).every(([e,t])=>String(i[e]??``)===t)?null:(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{className:`mb-0.5 block text-xs text-fg-faint`,children:[D(e.label),e.required?` *`:``]}),e.fieldType===`select`&&e.options?(0,h.jsx)(`select`,{className:_,value:String(i[e.key]??e.options[0]?.value??``),onChange:t=>y(r,e.key,t.target.value),children:e.options.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,h.jsx)(`input`,{className:_,type:e.secret?`password`:`text`,value:String(i[e.key]??``),onChange:t=>y(r,e.key,t.target.value),placeholder:e.placeholder,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`})]},e.key))]})]},r)}),m?(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-dashed border-border-default p-3`,children:[(0,h.jsx)(`input`,{className:_+` max-w-[160px]`,value:g,onChange:e=>T(e.target.value),placeholder:D(`ds.connectionName`),autoComplete:`off`,autoFocus:!0,onKeyDown:e=>e.key===`Enter`&&x()}),(0,h.jsx)(`select`,{className:_+` max-w-[120px]`,value:v,onChange:e=>E(e.target.value),children:n.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,h.jsx)(`button`,{type:`button`,onClick:x,disabled:!g.trim(),className:`rounded-md bg-brand-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-500 disabled:opacity-40`,children:D(`ds.add`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>w(!1),className:`text-xs text-fg-faint hover:text-fg-default`,children:D(`common.cancel`)})]}):(0,h.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex items-center gap-1 rounded-md border border-dashed border-border-default px-3 py-1.5 text-xs text-fg-muted hover:bg-bg-raised`,children:[(0,h.jsx)(f,{size:12}),` `,D(`ds.addDataSource`)]}),l&&(0,h.jsx)(`div`,{className:`rounded-md border border-rose-700/50 bg-rose-950/40 px-3 py-2 text-xs text-danger`,children:l}),(0,h.jsx)(`div`,{className:`flex items-center gap-2 border-t border-border-subtle pt-3`,children:(0,h.jsxs)(`button`,{type:`button`,onClick:S,disabled:!a||o,className:`inline-flex items-center gap-1.5 rounded-md bg-brand-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-500 disabled:cursor-not-allowed disabled:opacity-50`,children:[o?(0,h.jsx)(i,{className:`inline h-3 w-3 animate-spin`}):null,D(`common.save`)]})})]})}export{S as DataSourceConfigForm};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{C as t,E as n,O as r,S as i,T as a,_ as o,b as s,g as c,k as l,v as u,w as d,x as f,y as p}from"./index-CQxDTKff.js";var m=e(l(),1),h=o(),g=[{id:`neo4j`,name:`Neo4j`,fields:[{key:`uri`,label:`ds.field.uri`,placeholder:`bolt://localhost:7687`,required:!0},{key:`username`,label:`ds.field.username`,placeholder:`neo4j`,required:!0},{key:`password`,label:`ds.field.password`,secret:!0,required:!0},{key:`database`,label:`ds.field.database`,placeholder:`neo4j`}]},{id:`mysql`,name:`MySQL`,fields:[{key:`host`,label:`ds.field.host`,placeholder:`localhost`,required:!0},{key:`port`,label:`ds.field.port`,placeholder:`3306`},{key:`username`,label:`ds.field.username`,placeholder:`root`,required:!0},{key:`password`,label:`ds.field.password`,secret:!0,required:!0},{key:`database`,label:`ds.field.database`,required:!0}]},{id:`rest`,name:`REST API`,fields:[{key:`baseUrl`,label:`ds.field.baseUrl`,placeholder:`https://api.example.com`,required:!0},{key:`headers`,label:`ds.field.headers`,placeholder:`{"Authorization": "Bearer ***"}`},{key:`timeout`,label:`ds.field.timeout`,placeholder:`30000`}]}],_=`w-full rounded-md border border-border-default bg-bg-elevated px-3 py-1.5 text-xs text-fg-default outline-none placeholder:text-fg-fainter focus:border-brand-500`,v=`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors`,y=`${v} border-accent text-accent`,b=`${v} border-transparent text-fg-muted hover:text-fg-default`,x=`/api/p/datasource`;function S({plugin:e}){let t=c(),[n,r]=(0,m.useState)(`user`),[i,o]=(0,m.useState)(!1),[s,l]=(0,m.useState)(g);return(0,m.useEffect)(()=>{let t=e.config?.connections;t&&typeof t==`object`&&o(!0)},[e]),(0,m.useEffect)(()=>{fetch(`${x}/types`,{credentials:`include`}).then(e=>e.ok?e.json():null).then(e=>{e?.types?.length>0&&l(e.types)}).catch(()=>{})},[]),(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-0 border-b border-border-subtle`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>r(`user`),className:n===`user`?y:b,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(p,{size:12}),t(`ds.myConnections`)]})}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>r(`tenant`),className:n===`tenant`?y:b,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(a,{size:12}),t(`ds.tenantConnections`)]})})]}),n===`tenant`&&i?(0,h.jsx)(C,{plugin:e,types:s}):(0,h.jsx)(w,{types:s})]})}function C({plugin:e,types:t}){let i=c(),a=n(e=>e.setPlugins),[o,s]=(0,m.useState)({}),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(null),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)(!1),[S,C]=(0,m.useState)(``),[w,E]=(0,m.useState)(t[0]?.id??``);(0,m.useEffect)(()=>{let t=e.config?.connections;t&&typeof t==`object`&&s(t)},[e.config]);function D(e,t,n){s(r=>({...r,[e]:{...r[e],[t]:n}})),u(!0)}function O(e){s(t=>{let n={...t};return delete n[e],n}),u(!0)}function k(){let e=S.trim().replace(/[^a-zA-Z0-9_-]/g,`-`);e&&!o[e]&&(s(t=>({...t,[e]:{type:w,description:``}})),C(``),b(!1),u(!0))}async function A(){f(!0),g(null);try{let e=await r.setPluginConfig(`datasource`,{connections:o});a(e.plugins),u(!1)}catch(e){g(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function j(e){v(t=>({...t,[e]:{ok:!1,msg:i(`ds.testing`)}}));try{let t=await(await fetch(`${x}/test/${encodeURIComponent(e)}`,{method:`POST`,credentials:`include`})).json();v(n=>({...n,[e]:{ok:!!t.ok,msg:t.ok?i(`ds.connected`):t.error||i(`ds.failed`)}}))}catch(t){v(n=>({...n,[e]:{ok:!1,msg:t instanceof Error?t.message:String(t)}}))}}return(0,h.jsx)(T,{connections:o,types:t,scope:`tenant`,dirty:l,saving:d,error:p,testResults:_,adding:y,newName:S,newType:w,onUpdateField:D,onRemove:O,onAdd:k,onSave:A,onTest:j,onSetAdding:b,onSetNewName:C,onSetNewType:E})}function w({types:e}){let t=c(),[n,r]=(0,m.useState)({}),[a,o]=(0,m.useState)(!1),[s,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)({}),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(``),[b,S]=(0,m.useState)(e[0]?.id??``),[C,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>{fetch(`${x}/user-connections`,{credentials:`include`}).then(e=>e.ok?e.json():null).then(e=>{e?.connections&&r(e.connections),w(!0)}).catch(()=>w(!0))},[]);function E(e,t,n){r(r=>({...r,[e]:{...r[e],[t]:n}})),o(!0)}async function D(e){r(t=>{let n={...t};return delete n[e],n});try{let t=await(await fetch(`${x}/user-connections/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`})).json();t.ok||d(t.error||`Delete failed`)}catch(e){d(e instanceof Error?e.message:String(e))}}function O(){let e=v.trim().replace(/[^a-zA-Z0-9_-]/g,`-`);e&&!n[e]&&(r(t=>({...t,[e]:{type:b,description:``}})),y(``),_(!1),o(!0))}let k=(0,m.useCallback)(async()=>{l(!0),d(null);try{let e=await(await fetch(`${x}/user-connections`,{method:`PUT`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({connections:n})})).json();if(!e.ok)throw Error(e.error||`Save failed`);o(!1)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[n]);async function A(e){p(n=>({...n,[e]:{ok:!1,msg:t(`ds.testing`)}}));try{a&&await k();let n=await(await fetch(`${x}/test/${encodeURIComponent(e)}`,{method:`POST`,credentials:`include`})).json();p(r=>({...r,[e]:{ok:!!n.ok,msg:n.ok?t(`ds.connected`):n.error||t(`ds.failed`)}}))}catch(t){p(n=>({...n,[e]:{ok:!1,msg:t instanceof Error?t.message:String(t)}}))}}return C?(0,h.jsx)(T,{connections:n,types:e,scope:`user`,dirty:a,saving:s,error:u,testResults:f,adding:g,newName:v,newType:b,onUpdateField:E,onRemove:D,onAdd:O,onSave:k,onTest:A,onSetAdding:_,onSetNewName:y,onSetNewType:S}):(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-faint`,children:[(0,h.jsx)(i,{size:12,className:`animate-spin`}),` Loading…`]})}function T({connections:e,types:n,scope:r,dirty:a,saving:o,error:l,testResults:p,adding:m,newName:g,newType:v,onUpdateField:y,onRemove:b,onAdd:x,onSave:S,onTest:C,onSetAdding:w,onSetNewName:T,onSetNewType:E}){let D=c(),O=Object.keys(e);return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[r===`tenant`&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.tenantHint`)}),r===`user`&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.userHint`)}),O.length===0&&!m&&(0,h.jsx)(`p`,{className:`text-xs text-fg-faint`,children:D(`ds.noConnections`)}),O.map(r=>{let i=e[r],a=n.find(e=>e.id===i.type),o=p[r];return(0,h.jsxs)(`div`,{className:`rounded-lg border border-border-subtle p-3 space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-[13px] font-medium text-fg-default`,children:r}),(0,h.jsx)(`span`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-xs text-fg-faint`,children:i.type})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>C(r),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs text-fg-muted hover:bg-bg-raised`,title:D(`ds.testConnection`),children:[(0,h.jsx)(u,{size:12}),` `,D(`ds.test`)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>b(r),className:`rounded p-1 text-fg-faint hover:bg-bg-raised hover:text-danger`,children:(0,h.jsx)(s,{size:12})})]})]}),o&&(0,h.jsxs)(`div`,{className:`flex items-center gap-1 text-xs ${o.ok?`text-success`:`text-danger`}`,children:[o.ok?(0,h.jsx)(d,{size:12}):(0,h.jsx)(t,{size:12}),o.msg]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`mb-0.5 block text-xs text-fg-faint`,children:D(`ds.description`)}),(0,h.jsx)(`input`,{className:_,value:String(i.description??``),onChange:e=>y(r,`description`,e.target.value),placeholder:D(`ds.descriptionPlaceholder`),autoComplete:`off`})]}),a?.fields.map(e=>e.showWhen&&!Object.entries(e.showWhen).every(([e,t])=>String(i[e]??``)===t)?null:(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{className:`mb-0.5 block text-xs text-fg-faint`,children:[D(e.label),e.required?` *`:``]}),e.fieldType===`select`&&e.options?(0,h.jsx)(`select`,{className:_,value:String(i[e.key]??e.options[0]?.value??``),onChange:t=>y(r,e.key,t.target.value),children:e.options.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,h.jsx)(`input`,{className:_,type:e.secret?`password`:`text`,value:String(i[e.key]??``),onChange:t=>y(r,e.key,t.target.value),placeholder:e.placeholder,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`})]},e.key))]})]},r)}),m?(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-dashed border-border-default p-3`,children:[(0,h.jsx)(`input`,{className:_+` max-w-[160px]`,value:g,onChange:e=>T(e.target.value),placeholder:D(`ds.connectionName`),autoComplete:`off`,autoFocus:!0,onKeyDown:e=>e.key===`Enter`&&x()}),(0,h.jsx)(`select`,{className:_+` max-w-[120px]`,value:v,onChange:e=>E(e.target.value),children:n.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,h.jsx)(`button`,{type:`button`,onClick:x,disabled:!g.trim(),className:`rounded-md bg-brand-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-500 disabled:opacity-40`,children:D(`ds.add`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>w(!1),className:`text-xs text-fg-faint hover:text-fg-default`,children:D(`common.cancel`)})]}):(0,h.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex items-center gap-1 rounded-md border border-dashed border-border-default px-3 py-1.5 text-xs text-fg-muted hover:bg-bg-raised`,children:[(0,h.jsx)(f,{size:12}),` `,D(`ds.addDataSource`)]}),l&&(0,h.jsx)(`div`,{className:`rounded-md border border-rose-700/50 bg-rose-950/40 px-3 py-2 text-xs text-danger`,children:l}),(0,h.jsx)(`div`,{className:`flex items-center gap-2 border-t border-border-subtle pt-3`,children:(0,h.jsxs)(`button`,{type:`button`,onClick:S,disabled:!a||o,className:`inline-flex items-center gap-1.5 rounded-md bg-brand-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-500 disabled:cursor-not-allowed disabled:opacity-50`,children:[o?(0,h.jsx)(i,{className:`inline h-3 w-3 animate-spin`}):null,D(`common.save`)]})})]})}export{S as DataSourceConfigForm};
|