@dudko.dev/agent-web-react 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -2
- package/dist/{elicitation-BTrJ5t3c.d.cts → elicitation-xMLll5W9.d.cts} +47 -3
- package/dist/{elicitation-BTrJ5t3c.d.ts → elicitation-xMLll5W9.d.ts} +47 -3
- package/dist/index.cjs +683 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +205 -7
- package/dist/index.d.ts +205 -7
- package/dist/index.js +672 -156
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/styles.css +264 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -109,6 +109,127 @@ var createApprovalQueue = () => {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
// src/questions.ts
|
|
113
|
+
var ASK_USER_TOOL_NAME = "ask_user";
|
|
114
|
+
var QUESTION_TIMEOUT_MS = 3e5;
|
|
115
|
+
var TIMER_MAX_MS = 2147483647;
|
|
116
|
+
var questionTimeoutOf = (askUser) => {
|
|
117
|
+
if (!askUser) return void 0;
|
|
118
|
+
const raw = askUser === true ? void 0 : askUser.timeoutMs;
|
|
119
|
+
if (raw === void 0 || raw === null) return QUESTION_TIMEOUT_MS;
|
|
120
|
+
if (typeof raw !== "number" || !(raw > 0) || raw > TIMER_MAX_MS) return void 0;
|
|
121
|
+
return Math.max(1, Math.floor(raw));
|
|
122
|
+
};
|
|
123
|
+
var askUserWith = (askUser, handler) => {
|
|
124
|
+
if (!askUser) return askUser;
|
|
125
|
+
if (askUser === true) return { onQuestion: handler };
|
|
126
|
+
return askUser.onQuestion ? askUser : { ...askUser, onQuestion: handler };
|
|
127
|
+
};
|
|
128
|
+
var DECLINED = { declined: true };
|
|
129
|
+
var createQuestionQueue = (options = {}) => {
|
|
130
|
+
const now = options.now ?? Date.now;
|
|
131
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
132
|
+
let disposed = false;
|
|
133
|
+
const list = () => [...waiting.values()].map((w) => w.question);
|
|
134
|
+
const changed = () => {
|
|
135
|
+
if (!disposed) options.onChange?.(list());
|
|
136
|
+
};
|
|
137
|
+
const handler = (request, ctx) => new Promise((resolve) => {
|
|
138
|
+
const signal = ctx?.signal;
|
|
139
|
+
if (disposed || signal?.aborted || waiting.has(request.id)) {
|
|
140
|
+
resolve(DECLINED);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const onAbort = () => {
|
|
144
|
+
if (waiting.get(request.id)?.settle !== settle) return;
|
|
145
|
+
settle(DECLINED);
|
|
146
|
+
changed();
|
|
147
|
+
};
|
|
148
|
+
const settle = (answer) => {
|
|
149
|
+
waiting.delete(request.id);
|
|
150
|
+
signal?.removeEventListener("abort", onAbort);
|
|
151
|
+
resolve(answer);
|
|
152
|
+
};
|
|
153
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
154
|
+
const timeoutMs = typeof options.timeoutMs === "function" ? options.timeoutMs() : options.timeoutMs;
|
|
155
|
+
waiting.set(request.id, {
|
|
156
|
+
question: {
|
|
157
|
+
...request,
|
|
158
|
+
options: request.options.map((o) => ({ ...o })),
|
|
159
|
+
...timeoutMs !== void 0 ? { expiresAt: now() + timeoutMs } : {}
|
|
160
|
+
},
|
|
161
|
+
settle
|
|
162
|
+
});
|
|
163
|
+
changed();
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
handler,
|
|
167
|
+
pending: list,
|
|
168
|
+
answer: (id, answer) => {
|
|
169
|
+
const entry = waiting.get(id);
|
|
170
|
+
if (!entry) return false;
|
|
171
|
+
entry.settle(answer);
|
|
172
|
+
changed();
|
|
173
|
+
return true;
|
|
174
|
+
},
|
|
175
|
+
cancel: (match) => {
|
|
176
|
+
let any = false;
|
|
177
|
+
for (const entry of [...waiting.values()]) {
|
|
178
|
+
if (match && !match(entry.question)) continue;
|
|
179
|
+
entry.settle(DECLINED);
|
|
180
|
+
any = true;
|
|
181
|
+
}
|
|
182
|
+
if (any) changed();
|
|
183
|
+
},
|
|
184
|
+
dispose: () => {
|
|
185
|
+
disposed = true;
|
|
186
|
+
for (const entry of [...waiting.values()]) entry.settle(DECLINED);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
var questionChoiceOf = (question, picked) => {
|
|
191
|
+
const chosen = question.options.map((o) => o.label).filter((label) => picked.includes(label));
|
|
192
|
+
if (chosen.length === 0) return void 0;
|
|
193
|
+
return { choice: question.multiple ? chosen : chosen.slice(0, 1) };
|
|
194
|
+
};
|
|
195
|
+
var questionOtherOf = (question, text) => question.allowOther && typeof text === "string" && text.trim() ? { other: text.trim() } : void 0;
|
|
196
|
+
var LABELS_ONLY = [
|
|
197
|
+
"The user chose: ",
|
|
198
|
+
"The user chose not to answer.",
|
|
199
|
+
"The user did not answer in time.",
|
|
200
|
+
"The question could not be put to the user",
|
|
201
|
+
"You have already asked the user "
|
|
202
|
+
];
|
|
203
|
+
var askUserOutputKept = (output, ok) => (
|
|
204
|
+
// A failed call is about the model's own arguments (a bad question): nobody was asked.
|
|
205
|
+
!ok || typeof output === "string" && LABELS_ONLY.some((start) => output.startsWith(start))
|
|
206
|
+
);
|
|
207
|
+
var withoutOutput = (call) => {
|
|
208
|
+
if (call.name !== ASK_USER_TOOL_NAME || askUserOutputKept(call.output, call.ok)) return call;
|
|
209
|
+
const { output: _dropped, ...rest } = call;
|
|
210
|
+
void _dropped;
|
|
211
|
+
return rest;
|
|
212
|
+
};
|
|
213
|
+
var withoutOwnWords = (event) => {
|
|
214
|
+
switch (event.type) {
|
|
215
|
+
case "step.tool-result": {
|
|
216
|
+
const cleaned = withoutOutput(event);
|
|
217
|
+
return cleaned === event ? event : { ...cleaned, output: void 0 };
|
|
218
|
+
}
|
|
219
|
+
case "step.complete": {
|
|
220
|
+
const calls = event.result.toolCalls;
|
|
221
|
+
const cleaned = calls.map(withoutOutput);
|
|
222
|
+
return cleaned.every((c, i) => c === calls[i]) ? event : { ...event, result: { ...event.result, toolCalls: cleaned } };
|
|
223
|
+
}
|
|
224
|
+
case "subagent.event": {
|
|
225
|
+
const inner = withoutOwnWords(event.event);
|
|
226
|
+
return inner === event.event ? event : { ...event, event: inner };
|
|
227
|
+
}
|
|
228
|
+
default:
|
|
229
|
+
return event;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
112
233
|
// src/state.ts
|
|
113
234
|
import {
|
|
114
235
|
isReplayedToolOutput
|
|
@@ -258,6 +379,35 @@ var answerElicitation = (state, event, stepId) => {
|
|
|
258
379
|
]
|
|
259
380
|
};
|
|
260
381
|
};
|
|
382
|
+
var addQuestion = (state, event, extra) => state.questions?.some((q) => q.id === event.id) ? state : {
|
|
383
|
+
...state,
|
|
384
|
+
questions: [
|
|
385
|
+
...state.questions ?? [],
|
|
386
|
+
{
|
|
387
|
+
id: event.id,
|
|
388
|
+
question: event.question,
|
|
389
|
+
options: event.options.map((o) => ({ ...o })),
|
|
390
|
+
multiple: event.multiple,
|
|
391
|
+
allowOther: event.allowOther,
|
|
392
|
+
...extra.stepId ? { stepId: extra.stepId } : {},
|
|
393
|
+
...extra.subagent ? { subagent: extra.subagent } : {},
|
|
394
|
+
...extra.remote ? { remote: true } : {},
|
|
395
|
+
status: "pending"
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
};
|
|
399
|
+
var answerQuestion = (state, event) => state.questions?.some((q) => q.id === event.id) ? {
|
|
400
|
+
...state,
|
|
401
|
+
questions: state.questions.map(
|
|
402
|
+
(q) => q.id === event.id ? {
|
|
403
|
+
...q,
|
|
404
|
+
status: event.action,
|
|
405
|
+
automatic: event.automatic,
|
|
406
|
+
...event.action === "choice" && event.choice ? { choice: [...event.choice] } : {},
|
|
407
|
+
...event.reason ? { reason: event.reason } : {}
|
|
408
|
+
} : q
|
|
409
|
+
)
|
|
410
|
+
} : state;
|
|
261
411
|
var patchSubagent = (subagents, id, fn) => subagents.map((s) => s.id === id ? fn(s) : s);
|
|
262
412
|
var runningStepId = (steps) => [...steps].reverse().find((s) => s.status === "running")?.id;
|
|
263
413
|
var applySubagentEvent = (view, event) => {
|
|
@@ -490,6 +640,25 @@ var applySubagent = (state, event, ancestors, ctx) => {
|
|
|
490
640
|
inner,
|
|
491
641
|
known.subagents.find((s) => s.id === event.id)?.stepId
|
|
492
642
|
);
|
|
643
|
+
// A helper (or a subagent the host defined) asks the person through the run's handler:
|
|
644
|
+
// the question is the person's to answer, like the run's own, marked with who asks.
|
|
645
|
+
case "user.question-asked": {
|
|
646
|
+
const asker = inner.subagent ?? { id: event.id, depth: ancestors.length + 1 };
|
|
647
|
+
const node = known.subagents.find((s) => s.id === asker.id);
|
|
648
|
+
return addQuestion(known, inner, {
|
|
649
|
+
...ctx.remote ? { remote: true } : {},
|
|
650
|
+
// The helper's own step ids mean nothing here: the step that delegated it does.
|
|
651
|
+
stepId: (node ?? known.subagents.find((s) => s.id === event.id))?.stepId,
|
|
652
|
+
subagent: {
|
|
653
|
+
id: asker.id,
|
|
654
|
+
depth: asker.depth,
|
|
655
|
+
...node ? { name: node.name } : {},
|
|
656
|
+
...node?.role ? { role: node.role } : {}
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
case "user.question-answered":
|
|
661
|
+
return answerQuestion(known, inner);
|
|
493
662
|
// What a subagent generated is in the same workspace: it shows in the turn (its step
|
|
494
663
|
// ids are its own, so it is tied to no step here).
|
|
495
664
|
case "media.generated":
|
|
@@ -951,6 +1120,15 @@ var applyEvent = (state, event, ctx) => {
|
|
|
951
1120
|
});
|
|
952
1121
|
case "mcp.elicitation-answered":
|
|
953
1122
|
return answerElicitation(state, event, runningStepId(state.steps));
|
|
1123
|
+
case "user.question-asked":
|
|
1124
|
+
return addQuestion(state, event, {
|
|
1125
|
+
// Asked in the tab that runs the agent: shown here, answered there only.
|
|
1126
|
+
...ctx.remote ? { remote: true } : {},
|
|
1127
|
+
stepId: event.step?.id,
|
|
1128
|
+
...event.subagent ? { subagent: event.subagent } : {}
|
|
1129
|
+
});
|
|
1130
|
+
case "user.question-answered":
|
|
1131
|
+
return answerQuestion(state, event);
|
|
954
1132
|
case "tool.approval-requested":
|
|
955
1133
|
return {
|
|
956
1134
|
...state,
|
|
@@ -1082,6 +1260,12 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1082
1260
|
(e) => e.status === "pending" ? { ...e, status: "cancelled", automatic: true, reason: "stopped" } : e
|
|
1083
1261
|
)
|
|
1084
1262
|
} : {},
|
|
1263
|
+
// Nobody is asked any more once the run has stopped.
|
|
1264
|
+
...state.questions ? {
|
|
1265
|
+
questions: state.questions.map(
|
|
1266
|
+
(q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
|
|
1267
|
+
)
|
|
1268
|
+
} : {},
|
|
1085
1269
|
messages: finalizeAssistant(
|
|
1086
1270
|
state.messages,
|
|
1087
1271
|
state.finalText || "Stopped.",
|
|
@@ -1200,8 +1384,9 @@ var agentStateReducer = (state, action) => {
|
|
|
1200
1384
|
return { ...state, remote };
|
|
1201
1385
|
}
|
|
1202
1386
|
case "event": {
|
|
1387
|
+
const event = withoutOwnWords(action.event);
|
|
1203
1388
|
const next = syncRunMessage(
|
|
1204
|
-
applyEvent(state,
|
|
1389
|
+
applyEvent(state, event, {
|
|
1205
1390
|
at: action.at,
|
|
1206
1391
|
attachments: action.attachments,
|
|
1207
1392
|
...action.remote ? { remote: true } : {},
|
|
@@ -1209,7 +1394,7 @@ var agentStateReducer = (state, action) => {
|
|
|
1209
1394
|
})
|
|
1210
1395
|
);
|
|
1211
1396
|
const cap = action.maxEvents ?? 200;
|
|
1212
|
-
const events = cap > 0 ? [...state.events,
|
|
1397
|
+
const events = cap > 0 ? [...state.events, event].slice(-cap) : [...state.events, event];
|
|
1213
1398
|
return { ...next, events };
|
|
1214
1399
|
}
|
|
1215
1400
|
case "undelivered":
|
|
@@ -1260,6 +1445,13 @@ var useAgent = (config, options = {}) => {
|
|
|
1260
1445
|
(decision) => approvals.settleAll(decision),
|
|
1261
1446
|
[approvals]
|
|
1262
1447
|
);
|
|
1448
|
+
const [pendingQuestions, setPendingQuestions] = useState([]);
|
|
1449
|
+
const [questionQueue] = useState(
|
|
1450
|
+
() => createQuestionQueue({
|
|
1451
|
+
timeoutMs: () => questionTimeoutOf(configRef.current.askUser),
|
|
1452
|
+
onChange: setPendingQuestions
|
|
1453
|
+
})
|
|
1454
|
+
);
|
|
1263
1455
|
const uiOnRequest = useCallback(
|
|
1264
1456
|
(req2, ctx) => (req2.app ? appApprovals : approvals).handler(req2, ctx),
|
|
1265
1457
|
[approvals, appApprovals]
|
|
@@ -1294,10 +1486,12 @@ var useAgent = (config, options = {}) => {
|
|
|
1294
1486
|
return;
|
|
1295
1487
|
}
|
|
1296
1488
|
const routeApprovals = optionsRef.current.approvals !== false && !cfg.toolApproval?.onRequest;
|
|
1297
|
-
const
|
|
1489
|
+
const askUser = optionsRef.current.questions !== false ? askUserWith(cfg.askUser, questionQueue.handler) : cfg.askUser;
|
|
1490
|
+
const built = {
|
|
1298
1491
|
...cfg,
|
|
1299
|
-
toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest }
|
|
1300
|
-
|
|
1492
|
+
...routeApprovals ? { toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest } } : {},
|
|
1493
|
+
...askUser !== cfg.askUser ? { askUser } : {}
|
|
1494
|
+
};
|
|
1301
1495
|
let cancelled = false;
|
|
1302
1496
|
setBuildStatus({ status: "initializing" });
|
|
1303
1497
|
createAgent(built).then((agent) => {
|
|
@@ -1370,8 +1564,9 @@ var useAgent = (config, options = {}) => {
|
|
|
1370
1564
|
abortRef.current?.abort();
|
|
1371
1565
|
settleAll({ approved: false, reason: "the view was closed" });
|
|
1372
1566
|
appApprovals.settleAll({ approved: false, reason: "the view was closed" });
|
|
1567
|
+
questionQueue.dispose();
|
|
1373
1568
|
},
|
|
1374
|
-
[settleAll, appApprovals]
|
|
1569
|
+
[settleAll, appApprovals, questionQueue]
|
|
1375
1570
|
);
|
|
1376
1571
|
const runRef = useRef(void 0);
|
|
1377
1572
|
const run = useCallback(
|
|
@@ -1439,6 +1634,7 @@ var useAgent = (config, options = {}) => {
|
|
|
1439
1634
|
startedRef.current = false;
|
|
1440
1635
|
controlRef.current = void 0;
|
|
1441
1636
|
settleAll({ approved: false, reason: "the run ended" });
|
|
1637
|
+
questionQueue.cancel();
|
|
1442
1638
|
dispatch({ type: "status", ...buildStatusRef.current });
|
|
1443
1639
|
if (stopped && !began && shownGoal.trim()) left = [shownGoal, ...left];
|
|
1444
1640
|
if (left.length > 0) {
|
|
@@ -1453,7 +1649,7 @@ var useAgent = (config, options = {}) => {
|
|
|
1453
1649
|
}
|
|
1454
1650
|
}
|
|
1455
1651
|
},
|
|
1456
|
-
[settleAll]
|
|
1652
|
+
[settleAll, questionQueue]
|
|
1457
1653
|
);
|
|
1458
1654
|
runRef.current = run;
|
|
1459
1655
|
const send = useCallback((text) => controlRef.current?.send(text) ?? false, []);
|
|
@@ -1489,7 +1685,12 @@ var useAgent = (config, options = {}) => {
|
|
|
1489
1685
|
const stop = useCallback(() => {
|
|
1490
1686
|
abortRef.current?.abort();
|
|
1491
1687
|
settleAll({ approved: false, reason: "stopped by the user" });
|
|
1492
|
-
|
|
1688
|
+
questionQueue.cancel();
|
|
1689
|
+
}, [settleAll, questionQueue]);
|
|
1690
|
+
const answerQuestion2 = useCallback(
|
|
1691
|
+
(id, answer) => questionQueue.answer(id, answer),
|
|
1692
|
+
[questionQueue]
|
|
1693
|
+
);
|
|
1493
1694
|
const reset = useCallback(() => {
|
|
1494
1695
|
dispatch({ type: "reset" });
|
|
1495
1696
|
void configRef.current.memory?.clear(sessionRef.current).catch(() => {
|
|
@@ -1614,6 +1815,8 @@ var useAgent = (config, options = {}) => {
|
|
|
1614
1815
|
pendingApprovals: pendingApprovalsOf(state),
|
|
1615
1816
|
approve,
|
|
1616
1817
|
deny,
|
|
1818
|
+
pendingQuestions,
|
|
1819
|
+
answerQuestion: answerQuestion2,
|
|
1617
1820
|
approvalMode,
|
|
1618
1821
|
setApprovalMode,
|
|
1619
1822
|
approveAppToolCall,
|
|
@@ -2636,6 +2839,25 @@ var defaultLabels = {
|
|
|
2636
2839
|
"no-tool-call": "no tool call was in progress"
|
|
2637
2840
|
},
|
|
2638
2841
|
elicitationDismiss: "Dismiss",
|
|
2842
|
+
questionLead: "The agent asks you",
|
|
2843
|
+
questionLeadHelper: (role) => role ? `The helper \u201C${role}\u201D asks you` : "A helper the agent started asks you",
|
|
2844
|
+
questionCount: (index, total) => `${index} of ${total}`,
|
|
2845
|
+
questionSeveral: "Pick one or more, then Send.",
|
|
2846
|
+
questionSend: "Send",
|
|
2847
|
+
questionOther: "Other\u2026",
|
|
2848
|
+
questionOtherLabel: "Your answer",
|
|
2849
|
+
questionSkip: "Skip",
|
|
2850
|
+
questionExpiresIn: (time) => `If you do not answer, the agent decides by itself in ${time}`,
|
|
2851
|
+
questionRemote: "Answered in the other tab, where the agent is running.",
|
|
2852
|
+
questionAutomatic: (reason) => `The agent went on without your answer: ${reason}.`,
|
|
2853
|
+
questionReasons: {
|
|
2854
|
+
timeout: "nobody answered in time",
|
|
2855
|
+
stopped: "the run was stopped",
|
|
2856
|
+
"handler-error": "the question could not be shown",
|
|
2857
|
+
"invalid-answer": "the answer did not fit the question",
|
|
2858
|
+
"cannot-park": "the question could not wait here"
|
|
2859
|
+
},
|
|
2860
|
+
questionDismiss: "Dismiss",
|
|
2639
2861
|
appFrom: (server) => `App from server \u201C${server}\u201D`,
|
|
2640
2862
|
appSandboxed: "sandboxed",
|
|
2641
2863
|
appSandboxedOrigin: "sandboxed on its own origin",
|
|
@@ -2727,6 +2949,7 @@ var NESTED = [
|
|
|
2727
2949
|
"decisionReasons",
|
|
2728
2950
|
"elicitationErrors",
|
|
2729
2951
|
"elicitationReasons",
|
|
2952
|
+
"questionReasons",
|
|
2730
2953
|
"fileKinds",
|
|
2731
2954
|
"appSandboxReasons"
|
|
2732
2955
|
];
|
|
@@ -2814,7 +3037,7 @@ var useAgentContext = () => {
|
|
|
2814
3037
|
var useOptionalAgentContext = () => useContext2(AgentContext);
|
|
2815
3038
|
|
|
2816
3039
|
// src/components/AgentChat.tsx
|
|
2817
|
-
import { useEffect as
|
|
3040
|
+
import { useEffect as useEffect17, useRef as useRef12, useState as useState17 } from "react";
|
|
2818
3041
|
import { createPortal as createPortal2 } from "react-dom";
|
|
2819
3042
|
|
|
2820
3043
|
// src/hooks/use-follow-scroll.ts
|
|
@@ -7492,8 +7715,279 @@ var ModelLoadBar = ({ load, className }) => {
|
|
|
7492
7715
|
] });
|
|
7493
7716
|
};
|
|
7494
7717
|
|
|
7495
|
-
// src/components/
|
|
7718
|
+
// src/components/QuestionPrompt.tsx
|
|
7719
|
+
import { useEffect as useEffect16, useId as useId2, useRef as useRef11, useState as useState16 } from "react";
|
|
7496
7720
|
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7721
|
+
var useNow2 = (active) => {
|
|
7722
|
+
const [now, setNow] = useState16(() => Date.now());
|
|
7723
|
+
useEffect16(() => {
|
|
7724
|
+
if (!active) return;
|
|
7725
|
+
setNow(Date.now());
|
|
7726
|
+
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
7727
|
+
return () => clearInterval(timer);
|
|
7728
|
+
}, [active]);
|
|
7729
|
+
return now;
|
|
7730
|
+
};
|
|
7731
|
+
var Expiry2 = ({ expiresAt, L }) => {
|
|
7732
|
+
const now = useNow2(true);
|
|
7733
|
+
return /* @__PURE__ */ jsx18("p", { className: "awr-question__expiry", children: L.questionExpiresIn(formatCountdown(expiresAt - now)) });
|
|
7734
|
+
};
|
|
7735
|
+
var reasonText2 = (q, L) => {
|
|
7736
|
+
const key = q.reason ?? q.status;
|
|
7737
|
+
return Object.hasOwn(L.questionReasons, key) ? L.questionReasons[key] : key;
|
|
7738
|
+
};
|
|
7739
|
+
var leadOf = (subagent, L) => subagent ? L.questionLeadHelper(previewValue(subagent.role ?? "", 60) || void 0, subagent.depth) : L.questionLead;
|
|
7740
|
+
var isTyping = (target) => target instanceof HTMLElement && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable);
|
|
7741
|
+
var QuestionCard = ({
|
|
7742
|
+
question: q,
|
|
7743
|
+
view,
|
|
7744
|
+
index,
|
|
7745
|
+
total,
|
|
7746
|
+
answer,
|
|
7747
|
+
showExpiry,
|
|
7748
|
+
showHelper,
|
|
7749
|
+
numberKeys,
|
|
7750
|
+
L
|
|
7751
|
+
}) => {
|
|
7752
|
+
const baseId = useId2();
|
|
7753
|
+
const textId = `${baseId}-q`;
|
|
7754
|
+
const otherId = `${baseId}-other`;
|
|
7755
|
+
const [picked, setPicked] = useState16([]);
|
|
7756
|
+
const [otherOpen, setOtherOpen] = useState16(false);
|
|
7757
|
+
const [otherText, setOtherText] = useState16("");
|
|
7758
|
+
const otherField = useRef11(null);
|
|
7759
|
+
const otherButton = useRef11(null);
|
|
7760
|
+
useEffect16(() => {
|
|
7761
|
+
if (otherOpen) otherField.current?.focus();
|
|
7762
|
+
}, [otherOpen]);
|
|
7763
|
+
const helper = showHelper && q.subagent ? { ...q.subagent, ...view?.subagent } : void 0;
|
|
7764
|
+
const choice = questionChoiceOf(q, picked);
|
|
7765
|
+
const other = questionOtherOf(q, otherText);
|
|
7766
|
+
const pick = (label) => {
|
|
7767
|
+
if (!q.multiple) {
|
|
7768
|
+
const one = questionChoiceOf(q, [label]);
|
|
7769
|
+
if (one) answer(one);
|
|
7770
|
+
return;
|
|
7771
|
+
}
|
|
7772
|
+
setPicked((p) => p.includes(label) ? p.filter((l) => l !== label) : [...p, label]);
|
|
7773
|
+
};
|
|
7774
|
+
const sendOther = (e) => {
|
|
7775
|
+
e.preventDefault();
|
|
7776
|
+
if (other) answer(other);
|
|
7777
|
+
};
|
|
7778
|
+
const onKeyDown = (e) => {
|
|
7779
|
+
if (!numberKeys || e.defaultPrevented || isTyping(e.target)) return;
|
|
7780
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
7781
|
+
const n = /^[1-9]$/.test(e.key) ? Number(e.key) : 0;
|
|
7782
|
+
const option = n ? q.options[n - 1] : void 0;
|
|
7783
|
+
if (!option) return;
|
|
7784
|
+
e.preventDefault();
|
|
7785
|
+
pick(option.label);
|
|
7786
|
+
};
|
|
7787
|
+
return /* @__PURE__ */ jsxs16(
|
|
7788
|
+
"section",
|
|
7789
|
+
{
|
|
7790
|
+
className: `awr-question${q.multiple ? " awr-question--multiple" : ""}${helper ? " awr-question--helper" : ""}`,
|
|
7791
|
+
role: "group",
|
|
7792
|
+
"aria-labelledby": textId,
|
|
7793
|
+
"data-question": q.id,
|
|
7794
|
+
"data-subagent": helper?.id,
|
|
7795
|
+
onKeyDown,
|
|
7796
|
+
children: [
|
|
7797
|
+
/* @__PURE__ */ jsxs16("div", { className: "awr-question__head", children: [
|
|
7798
|
+
/* @__PURE__ */ jsx18(QuestionIcon, { size: 16, className: "awr-question__icon" }),
|
|
7799
|
+
/* @__PURE__ */ jsx18("span", { className: "awr-question__lead", role: "alert", children: leadOf(helper, L) }),
|
|
7800
|
+
total > 1 && /* @__PURE__ */ jsx18("span", { className: "awr-question__count", children: L.questionCount(index, total) })
|
|
7801
|
+
] }),
|
|
7802
|
+
/* @__PURE__ */ jsx18("p", { className: "awr-question__text", id: textId, children: q.question }),
|
|
7803
|
+
q.multiple && /* @__PURE__ */ jsx18("p", { className: "awr-question__hint", children: L.questionSeveral }),
|
|
7804
|
+
/* @__PURE__ */ jsx18("div", { className: "awr-question__options", children: q.options.map((o, i) => {
|
|
7805
|
+
const on = picked.includes(o.label);
|
|
7806
|
+
return /* @__PURE__ */ jsxs16(
|
|
7807
|
+
"button",
|
|
7808
|
+
{
|
|
7809
|
+
type: "button",
|
|
7810
|
+
className: `awr-question__option${on ? " is-picked" : ""}`,
|
|
7811
|
+
"data-option": i + 1,
|
|
7812
|
+
"aria-pressed": q.multiple ? on : void 0,
|
|
7813
|
+
"aria-keyshortcuts": numberKeys && i < 9 ? String(i + 1) : void 0,
|
|
7814
|
+
onClick: () => pick(o.label),
|
|
7815
|
+
children: [
|
|
7816
|
+
numberKeys && i < 9 && /* @__PURE__ */ jsx18("span", { className: "awr-question__key", "aria-hidden": "true", children: i + 1 }),
|
|
7817
|
+
/* @__PURE__ */ jsxs16("span", { className: "awr-question__body", children: [
|
|
7818
|
+
/* @__PURE__ */ jsx18("span", { className: "awr-question__label", children: o.label }),
|
|
7819
|
+
o.description && /* @__PURE__ */ jsx18("span", { className: "awr-question__desc", children: o.description })
|
|
7820
|
+
] }),
|
|
7821
|
+
q.multiple && /* @__PURE__ */ jsx18("span", { className: "awr-question__mark", "aria-hidden": "true", children: on && /* @__PURE__ */ jsx18(CheckIcon, { size: 14 }) })
|
|
7822
|
+
]
|
|
7823
|
+
},
|
|
7824
|
+
o.label
|
|
7825
|
+
);
|
|
7826
|
+
}) }),
|
|
7827
|
+
q.allowOther && otherOpen && /* @__PURE__ */ jsxs16("form", { className: "awr-question__other", onSubmit: sendOther, children: [
|
|
7828
|
+
/* @__PURE__ */ jsx18("label", { className: "awr-question__otherlabel", htmlFor: otherId, children: L.questionOtherLabel }),
|
|
7829
|
+
/* @__PURE__ */ jsxs16("div", { className: "awr-question__otherrow", children: [
|
|
7830
|
+
/* @__PURE__ */ jsx18(
|
|
7831
|
+
"input",
|
|
7832
|
+
{
|
|
7833
|
+
ref: otherField,
|
|
7834
|
+
id: otherId,
|
|
7835
|
+
className: "awr-question__input",
|
|
7836
|
+
type: "text",
|
|
7837
|
+
value: otherText,
|
|
7838
|
+
autoComplete: "off",
|
|
7839
|
+
onChange: (e) => setOtherText(e.target.value),
|
|
7840
|
+
onKeyDown: (e) => {
|
|
7841
|
+
if (e.key !== "Escape") return;
|
|
7842
|
+
e.preventDefault();
|
|
7843
|
+
e.stopPropagation();
|
|
7844
|
+
setOtherOpen(false);
|
|
7845
|
+
otherButton.current?.focus();
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7848
|
+
),
|
|
7849
|
+
/* @__PURE__ */ jsx18("button", { type: "submit", className: "awr-btn awr-btn--primary", disabled: !other, children: L.questionSend })
|
|
7850
|
+
] })
|
|
7851
|
+
] }),
|
|
7852
|
+
/* @__PURE__ */ jsxs16("div", { className: "awr-question__actions", children: [
|
|
7853
|
+
q.multiple && !otherOpen && /* @__PURE__ */ jsx18(
|
|
7854
|
+
"button",
|
|
7855
|
+
{
|
|
7856
|
+
type: "button",
|
|
7857
|
+
className: "awr-btn awr-btn--primary",
|
|
7858
|
+
disabled: !choice,
|
|
7859
|
+
onClick: () => choice && answer(choice),
|
|
7860
|
+
children: L.questionSend
|
|
7861
|
+
}
|
|
7862
|
+
),
|
|
7863
|
+
q.allowOther && /* @__PURE__ */ jsx18(
|
|
7864
|
+
"button",
|
|
7865
|
+
{
|
|
7866
|
+
ref: otherButton,
|
|
7867
|
+
type: "button",
|
|
7868
|
+
className: "awr-btn",
|
|
7869
|
+
"aria-expanded": otherOpen,
|
|
7870
|
+
"aria-controls": otherOpen ? otherId : void 0,
|
|
7871
|
+
onClick: () => setOtherOpen((o) => !o),
|
|
7872
|
+
children: L.questionOther
|
|
7873
|
+
}
|
|
7874
|
+
),
|
|
7875
|
+
/* @__PURE__ */ jsx18(
|
|
7876
|
+
"button",
|
|
7877
|
+
{
|
|
7878
|
+
type: "button",
|
|
7879
|
+
className: "awr-btn awr-btn--ghost",
|
|
7880
|
+
onClick: () => answer({ declined: true }),
|
|
7881
|
+
children: L.questionSkip
|
|
7882
|
+
}
|
|
7883
|
+
)
|
|
7884
|
+
] }),
|
|
7885
|
+
showExpiry && q.expiresAt !== void 0 && /* @__PURE__ */ jsx18(Expiry2, { expiresAt: q.expiresAt, L })
|
|
7886
|
+
]
|
|
7887
|
+
}
|
|
7888
|
+
);
|
|
7889
|
+
};
|
|
7890
|
+
var RemoteQuestion = ({ view, L }) => {
|
|
7891
|
+
const textId = `${useId2()}-q`;
|
|
7892
|
+
return /* @__PURE__ */ jsxs16(
|
|
7893
|
+
"section",
|
|
7894
|
+
{
|
|
7895
|
+
className: "awr-question awr-question--remote",
|
|
7896
|
+
role: "group",
|
|
7897
|
+
"aria-labelledby": textId,
|
|
7898
|
+
"data-question": view.id,
|
|
7899
|
+
children: [
|
|
7900
|
+
/* @__PURE__ */ jsxs16("div", { className: "awr-question__head", children: [
|
|
7901
|
+
/* @__PURE__ */ jsx18(QuestionIcon, { size: 16, className: "awr-question__icon" }),
|
|
7902
|
+
/* @__PURE__ */ jsx18("span", { className: "awr-question__lead", children: leadOf(view.subagent, L) })
|
|
7903
|
+
] }),
|
|
7904
|
+
/* @__PURE__ */ jsx18("p", { className: "awr-question__text", id: textId, children: view.question }),
|
|
7905
|
+
/* @__PURE__ */ jsx18("ul", { className: "awr-question__list", children: view.options.map((o) => /* @__PURE__ */ jsxs16("li", { children: [
|
|
7906
|
+
/* @__PURE__ */ jsx18("span", { className: "awr-question__label", children: o.label }),
|
|
7907
|
+
o.description && /* @__PURE__ */ jsx18("span", { className: "awr-question__desc", children: o.description })
|
|
7908
|
+
] }, o.label)) }),
|
|
7909
|
+
/* @__PURE__ */ jsx18("p", { className: "awr-question__remote", role: "status", children: L.questionRemote })
|
|
7910
|
+
]
|
|
7911
|
+
}
|
|
7912
|
+
);
|
|
7913
|
+
};
|
|
7914
|
+
var QuestionPrompt = ({
|
|
7915
|
+
questions,
|
|
7916
|
+
onAnswer,
|
|
7917
|
+
outcomes,
|
|
7918
|
+
showOutcomes = true,
|
|
7919
|
+
showExpiry = true,
|
|
7920
|
+
showHelper = true,
|
|
7921
|
+
showRemote = true,
|
|
7922
|
+
numberKeys = true,
|
|
7923
|
+
renderQuestion,
|
|
7924
|
+
labels,
|
|
7925
|
+
className
|
|
7926
|
+
}) => {
|
|
7927
|
+
const L = useLabels(labels);
|
|
7928
|
+
const [dismissed, setDismissed] = useState16(() => /* @__PURE__ */ new Set());
|
|
7929
|
+
const automatic = showOutcomes ? (outcomes ?? []).filter(
|
|
7930
|
+
(o) => o.automatic === true && o.status !== "pending" && o.status !== "stopped" && !dismissed.has(o.id)
|
|
7931
|
+
) : [];
|
|
7932
|
+
const remote = showRemote ? (outcomes ?? []).filter((o) => o.remote && o.status === "pending") : [];
|
|
7933
|
+
const current = questions[0];
|
|
7934
|
+
if (!current && automatic.length === 0 && remote.length === 0) return null;
|
|
7935
|
+
let card = null;
|
|
7936
|
+
if (current) {
|
|
7937
|
+
const answer = (a) => onAnswer(current.id, a);
|
|
7938
|
+
const builtIn = /* @__PURE__ */ jsx18(
|
|
7939
|
+
QuestionCard,
|
|
7940
|
+
{
|
|
7941
|
+
question: current,
|
|
7942
|
+
view: outcomes?.find((o) => o.id === current.id),
|
|
7943
|
+
index: 1,
|
|
7944
|
+
total: questions.length,
|
|
7945
|
+
answer,
|
|
7946
|
+
showExpiry,
|
|
7947
|
+
showHelper,
|
|
7948
|
+
numberKeys,
|
|
7949
|
+
L
|
|
7950
|
+
},
|
|
7951
|
+
current.id
|
|
7952
|
+
);
|
|
7953
|
+
card = renderQuestion ? renderQuestion(current, builtIn, answer) : builtIn;
|
|
7954
|
+
}
|
|
7955
|
+
return /* @__PURE__ */ jsxs16("div", { className: ["awr-questions", className].filter(Boolean).join(" "), children: [
|
|
7956
|
+
automatic.map((o) => /* @__PURE__ */ jsxs16(
|
|
7957
|
+
"div",
|
|
7958
|
+
{
|
|
7959
|
+
className: "awr-question-outcome",
|
|
7960
|
+
role: "status",
|
|
7961
|
+
"data-reason": o.reason ?? o.status,
|
|
7962
|
+
children: [
|
|
7963
|
+
/* @__PURE__ */ jsx18(AlertIcon, { size: 14, className: "awr-question-outcome__icon" }),
|
|
7964
|
+
/* @__PURE__ */ jsxs16("span", { className: "awr-question-outcome__text", children: [
|
|
7965
|
+
L.questionAutomatic(reasonText2(o, L)),
|
|
7966
|
+
" ",
|
|
7967
|
+
/* @__PURE__ */ jsx18("q", { className: "awr-question-outcome__question", children: o.question })
|
|
7968
|
+
] }),
|
|
7969
|
+
/* @__PURE__ */ jsx18(
|
|
7970
|
+
"button",
|
|
7971
|
+
{
|
|
7972
|
+
type: "button",
|
|
7973
|
+
className: "awr-iconbtn awr-question-outcome__dismiss",
|
|
7974
|
+
"aria-label": L.questionDismiss,
|
|
7975
|
+
title: L.questionDismiss,
|
|
7976
|
+
onClick: () => setDismissed((d) => new Set(d).add(o.id)),
|
|
7977
|
+
children: /* @__PURE__ */ jsx18(XIcon, { size: 14 })
|
|
7978
|
+
}
|
|
7979
|
+
)
|
|
7980
|
+
]
|
|
7981
|
+
},
|
|
7982
|
+
o.id
|
|
7983
|
+
)),
|
|
7984
|
+
remote.map((o) => /* @__PURE__ */ jsx18(RemoteQuestion, { view: o, L }, o.id)),
|
|
7985
|
+
card
|
|
7986
|
+
] });
|
|
7987
|
+
};
|
|
7988
|
+
|
|
7989
|
+
// src/components/ToolApprovalPrompt.tsx
|
|
7990
|
+
import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7497
7991
|
var SkillConsentCard = ({
|
|
7498
7992
|
approval: a,
|
|
7499
7993
|
skill,
|
|
@@ -7503,7 +7997,7 @@ var SkillConsentCard = ({
|
|
|
7503
7997
|
showPreview,
|
|
7504
7998
|
onApprove,
|
|
7505
7999
|
onDeny
|
|
7506
|
-
}) => /* @__PURE__ */
|
|
8000
|
+
}) => /* @__PURE__ */ jsxs17(
|
|
7507
8001
|
"div",
|
|
7508
8002
|
{
|
|
7509
8003
|
className: `awr-approval awr-approval--skill${helper ? " awr-approval--helper" : ""}`,
|
|
@@ -7511,28 +8005,28 @@ var SkillConsentCard = ({
|
|
|
7511
8005
|
"data-skill-server": skill.server,
|
|
7512
8006
|
"data-subagent": helper?.id,
|
|
7513
8007
|
children: [
|
|
7514
|
-
/* @__PURE__ */
|
|
7515
|
-
/* @__PURE__ */
|
|
7516
|
-
/* @__PURE__ */
|
|
8008
|
+
/* @__PURE__ */ jsxs17("div", { className: "awr-approval__head", children: [
|
|
8009
|
+
/* @__PURE__ */ jsx19(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
|
|
8010
|
+
/* @__PURE__ */ jsx19("span", { children: L.skillConsentLead(skill.server, skill.skill) })
|
|
7517
8011
|
] }),
|
|
7518
|
-
skill.description && /* @__PURE__ */
|
|
7519
|
-
/* @__PURE__ */
|
|
7520
|
-
/* @__PURE__ */
|
|
7521
|
-
/* @__PURE__ */
|
|
8012
|
+
skill.description && /* @__PURE__ */ jsx19("p", { className: "awr-approval__quote", children: skill.description }),
|
|
8013
|
+
/* @__PURE__ */ jsxs17("p", { className: "awr-approval__skillmeta", children: [
|
|
8014
|
+
/* @__PURE__ */ jsx19("code", { className: "awr-tool__name", children: skill.name }),
|
|
8015
|
+
/* @__PURE__ */ jsx19("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
|
|
7522
8016
|
] }),
|
|
7523
|
-
skill.byUri && /* @__PURE__ */
|
|
7524
|
-
skill.nestedIn && /* @__PURE__ */
|
|
7525
|
-
skill.dynamic && /* @__PURE__ */
|
|
7526
|
-
skill.dynamic && skill.noFileListing && /* @__PURE__ */
|
|
7527
|
-
showPreview && skill.body !== void 0 && /* @__PURE__ */
|
|
7528
|
-
/* @__PURE__ */
|
|
7529
|
-
/* @__PURE__ */
|
|
7530
|
-
skill.files.length > 0 && /* @__PURE__ */
|
|
8017
|
+
skill.byUri && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
|
|
8018
|
+
skill.nestedIn && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
|
|
8019
|
+
skill.dynamic && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
|
|
8020
|
+
skill.dynamic && skill.noFileListing && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
|
|
8021
|
+
showPreview && skill.body !== void 0 && /* @__PURE__ */ jsxs17("details", { className: "awr-approval__preview", children: [
|
|
8022
|
+
/* @__PURE__ */ jsx19("summary", { children: L.skillConsentPreview }),
|
|
8023
|
+
/* @__PURE__ */ jsx19("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
|
|
8024
|
+
skill.files.length > 0 && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentFiles(skill.files.join(", "), skill.fileCount - skill.files.length) })
|
|
7531
8025
|
] }),
|
|
7532
|
-
/* @__PURE__ */
|
|
7533
|
-
/* @__PURE__ */
|
|
7534
|
-
/* @__PURE__ */
|
|
7535
|
-
allowRemember && /* @__PURE__ */
|
|
8026
|
+
/* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
|
|
8027
|
+
/* @__PURE__ */ jsxs17("div", { className: "awr-approval__actions", children: [
|
|
8028
|
+
/* @__PURE__ */ jsx19("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
|
|
8029
|
+
allowRemember && /* @__PURE__ */ jsx19(
|
|
7536
8030
|
"button",
|
|
7537
8031
|
{
|
|
7538
8032
|
type: "button",
|
|
@@ -7541,7 +8035,7 @@ var SkillConsentCard = ({
|
|
|
7541
8035
|
children: L.skillConsentAlways
|
|
7542
8036
|
}
|
|
7543
8037
|
),
|
|
7544
|
-
/* @__PURE__ */
|
|
8038
|
+
/* @__PURE__ */ jsx19(
|
|
7545
8039
|
"button",
|
|
7546
8040
|
{
|
|
7547
8041
|
type: "button",
|
|
@@ -7567,9 +8061,9 @@ var ToolApprovalPrompt = ({
|
|
|
7567
8061
|
}) => {
|
|
7568
8062
|
const L = useLabels(labels);
|
|
7569
8063
|
if (approvals.length === 0) return null;
|
|
7570
|
-
return /* @__PURE__ */
|
|
8064
|
+
return /* @__PURE__ */ jsx19("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
|
|
7571
8065
|
if (a.skill) {
|
|
7572
|
-
const card2 = /* @__PURE__ */
|
|
8066
|
+
const card2 = /* @__PURE__ */ jsx19(
|
|
7573
8067
|
SkillConsentCard,
|
|
7574
8068
|
{
|
|
7575
8069
|
approval: a,
|
|
@@ -7583,33 +8077,33 @@ var ToolApprovalPrompt = ({
|
|
|
7583
8077
|
},
|
|
7584
8078
|
a.id
|
|
7585
8079
|
);
|
|
7586
|
-
return renderApproval ? /* @__PURE__ */
|
|
8080
|
+
return renderApproval ? /* @__PURE__ */ jsx19("div", { children: renderApproval(a, card2) }, a.id) : card2;
|
|
7587
8081
|
}
|
|
7588
8082
|
const helper = showHelper ? a.subagent : void 0;
|
|
7589
8083
|
const app = a.app;
|
|
7590
|
-
const card = /* @__PURE__ */
|
|
8084
|
+
const card = /* @__PURE__ */ jsxs17(
|
|
7591
8085
|
"div",
|
|
7592
8086
|
{
|
|
7593
8087
|
className: `awr-approval${helper ? " awr-approval--helper" : ""}${app ? " awr-approval--app" : ""}`,
|
|
7594
8088
|
"data-subagent": helper?.id,
|
|
7595
8089
|
"data-app-server": app?.server,
|
|
7596
8090
|
children: [
|
|
7597
|
-
/* @__PURE__ */
|
|
7598
|
-
/* @__PURE__ */
|
|
7599
|
-
/* @__PURE__ */
|
|
8091
|
+
/* @__PURE__ */ jsxs17("div", { className: "awr-approval__head", children: [
|
|
8092
|
+
/* @__PURE__ */ jsx19(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
|
|
8093
|
+
/* @__PURE__ */ jsxs17("span", { children: [
|
|
7600
8094
|
app ? L.approvalLeadApp(app.server) : helper ? L.approvalLeadHelper(
|
|
7601
8095
|
previewValue(helper.role ?? "", 60) || void 0,
|
|
7602
8096
|
helper.depth
|
|
7603
8097
|
) : L.approvalLead,
|
|
7604
8098
|
" ",
|
|
7605
|
-
/* @__PURE__ */
|
|
8099
|
+
/* @__PURE__ */ jsx19("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
|
|
7606
8100
|
a.readOnly && !app ? ` (${L.readOnlyTool})` : ""
|
|
7607
8101
|
] })
|
|
7608
8102
|
] }),
|
|
7609
|
-
previewValue(a.input, 300) && /* @__PURE__ */
|
|
7610
|
-
app && /* @__PURE__ */
|
|
7611
|
-
/* @__PURE__ */
|
|
7612
|
-
/* @__PURE__ */
|
|
8103
|
+
previewValue(a.input, 300) && /* @__PURE__ */ jsx19("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
|
|
8104
|
+
app && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
|
|
8105
|
+
/* @__PURE__ */ jsxs17("div", { className: "awr-approval__actions", children: [
|
|
8106
|
+
/* @__PURE__ */ jsx19(
|
|
7613
8107
|
"button",
|
|
7614
8108
|
{
|
|
7615
8109
|
type: "button",
|
|
@@ -7618,7 +8112,7 @@ var ToolApprovalPrompt = ({
|
|
|
7618
8112
|
children: L.approve
|
|
7619
8113
|
}
|
|
7620
8114
|
),
|
|
7621
|
-
allowRemember && /* @__PURE__ */
|
|
8115
|
+
allowRemember && /* @__PURE__ */ jsx19(
|
|
7622
8116
|
"button",
|
|
7623
8117
|
{
|
|
7624
8118
|
type: "button",
|
|
@@ -7627,7 +8121,7 @@ var ToolApprovalPrompt = ({
|
|
|
7627
8121
|
children: L.alwaysAllow
|
|
7628
8122
|
}
|
|
7629
8123
|
),
|
|
7630
|
-
/* @__PURE__ */
|
|
8124
|
+
/* @__PURE__ */ jsx19(
|
|
7631
8125
|
"button",
|
|
7632
8126
|
{
|
|
7633
8127
|
type: "button",
|
|
@@ -7641,12 +8135,12 @@ var ToolApprovalPrompt = ({
|
|
|
7641
8135
|
},
|
|
7642
8136
|
a.id
|
|
7643
8137
|
);
|
|
7644
|
-
return renderApproval ? /* @__PURE__ */
|
|
8138
|
+
return renderApproval ? /* @__PURE__ */ jsx19("div", { children: renderApproval(a, card) }, a.id) : card;
|
|
7645
8139
|
}) });
|
|
7646
8140
|
};
|
|
7647
8141
|
|
|
7648
8142
|
// src/components/UsageBadge.tsx
|
|
7649
|
-
import { jsxs as
|
|
8143
|
+
import { jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7650
8144
|
var UsageBadge = ({
|
|
7651
8145
|
usage,
|
|
7652
8146
|
compact = false,
|
|
@@ -7672,7 +8166,7 @@ var UsageBadge = ({
|
|
|
7672
8166
|
mediaText,
|
|
7673
8167
|
decisions ? L.usageDecisions(decisions) : ""
|
|
7674
8168
|
].filter(Boolean).join(" \xB7 ");
|
|
7675
|
-
return /* @__PURE__ */
|
|
8169
|
+
return /* @__PURE__ */ jsxs18("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
|
|
7676
8170
|
formatTokens(usage.inputTokens),
|
|
7677
8171
|
"\u2191 ",
|
|
7678
8172
|
formatTokens(usage.outputTokens),
|
|
@@ -7685,13 +8179,13 @@ var UsageBadge = ({
|
|
|
7685
8179
|
};
|
|
7686
8180
|
|
|
7687
8181
|
// src/components/AgentChat.tsx
|
|
7688
|
-
import { Fragment as Fragment11, jsx as
|
|
8182
|
+
import { Fragment as Fragment11, jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7689
8183
|
var usePrefersDark = () => {
|
|
7690
8184
|
const query = "(prefers-color-scheme: dark)";
|
|
7691
|
-
const [dark, setDark] =
|
|
8185
|
+
const [dark, setDark] = useState17(
|
|
7692
8186
|
() => typeof matchMedia === "function" && matchMedia(query).matches
|
|
7693
8187
|
);
|
|
7694
|
-
|
|
8188
|
+
useEffect17(() => {
|
|
7695
8189
|
if (typeof matchMedia !== "function") return;
|
|
7696
8190
|
const mq = matchMedia(query);
|
|
7697
8191
|
const on = () => setDark(mq.matches);
|
|
@@ -7702,7 +8196,7 @@ var usePrefersDark = () => {
|
|
|
7702
8196
|
};
|
|
7703
8197
|
var isHistoryHook = (h) => typeof h === "object" && h !== null && "select" in h && "chats" in h;
|
|
7704
8198
|
var cx = (...names) => names.filter(Boolean).join(" ");
|
|
7705
|
-
var AgentChat = (props) => /* @__PURE__ */
|
|
8199
|
+
var AgentChat = (props) => /* @__PURE__ */ jsx20(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ jsx20(AgentChatInner, { ...props }) });
|
|
7706
8200
|
var NO_LABELS = {};
|
|
7707
8201
|
var AgentChatInner = ({
|
|
7708
8202
|
controller,
|
|
@@ -7730,11 +8224,13 @@ var AgentChatInner = ({
|
|
|
7730
8224
|
showContext = false,
|
|
7731
8225
|
activityOpen = false,
|
|
7732
8226
|
showElicitation = true,
|
|
8227
|
+
showQuestions = true,
|
|
7733
8228
|
showSkillPreview = true,
|
|
7734
8229
|
showOtherTabs = true,
|
|
7735
8230
|
elicitations,
|
|
7736
8231
|
onElicitationAnswer,
|
|
7737
8232
|
renderElicitation,
|
|
8233
|
+
renderQuestion,
|
|
7738
8234
|
history,
|
|
7739
8235
|
defaultHistoryOpen,
|
|
7740
8236
|
files,
|
|
@@ -7779,7 +8275,7 @@ var AgentChatInner = ({
|
|
|
7779
8275
|
}
|
|
7780
8276
|
const L = useLabels();
|
|
7781
8277
|
const external = isHistoryHook(history) ? history : void 0;
|
|
7782
|
-
const [ownStore] =
|
|
8278
|
+
const [ownStore] = useState17(
|
|
7783
8279
|
() => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
|
|
7784
8280
|
);
|
|
7785
8281
|
const own = useChatHistory(agent, {
|
|
@@ -7787,9 +8283,9 @@ var AgentChatInner = ({
|
|
|
7787
8283
|
enabled: Boolean(history) && !external
|
|
7788
8284
|
});
|
|
7789
8285
|
const chats = history ? external ?? own : void 0;
|
|
7790
|
-
const rootRef =
|
|
7791
|
-
const [narrow, setNarrow] =
|
|
7792
|
-
|
|
8286
|
+
const rootRef = useRef12(null);
|
|
8287
|
+
const [narrow, setNarrow] = useState17(void 0);
|
|
8288
|
+
useEffect17(() => {
|
|
7793
8289
|
const el = rootRef.current;
|
|
7794
8290
|
if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
|
|
7795
8291
|
const measure2 = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
|
|
@@ -7798,9 +8294,9 @@ var AgentChatInner = ({
|
|
|
7798
8294
|
ro.observe(el);
|
|
7799
8295
|
return () => ro.disconnect();
|
|
7800
8296
|
}, [narrowWidth]);
|
|
7801
|
-
const [historyChoice, setHistoryOpen] =
|
|
8297
|
+
const [historyChoice, setHistoryOpen] = useState17(defaultHistoryOpen);
|
|
7802
8298
|
const historyOpen = historyChoice ?? narrow === false;
|
|
7803
|
-
const [filesOpen, setFilesOpen] =
|
|
8299
|
+
const [filesOpen, setFilesOpen] = useState17(defaultFilesOpen);
|
|
7804
8300
|
const toggleHistory = () => {
|
|
7805
8301
|
setHistoryOpen(!historyOpen);
|
|
7806
8302
|
if (narrow && !historyOpen) setFilesOpen(false);
|
|
@@ -7818,7 +8314,7 @@ var AgentChatInner = ({
|
|
|
7818
8314
|
setHistoryOpen(false);
|
|
7819
8315
|
setFilesOpen(false);
|
|
7820
8316
|
};
|
|
7821
|
-
|
|
8317
|
+
useEffect17(() => {
|
|
7822
8318
|
if (!overlayOpen) return;
|
|
7823
8319
|
const onKey = (e) => {
|
|
7824
8320
|
if (e.key !== "Escape" || e.defaultPrevented) return;
|
|
@@ -7828,7 +8324,7 @@ var AgentChatInner = ({
|
|
|
7828
8324
|
document.addEventListener("keydown", onKey);
|
|
7829
8325
|
return () => document.removeEventListener("keydown", onKey);
|
|
7830
8326
|
}, [overlayOpen]);
|
|
7831
|
-
const bodyRef =
|
|
8327
|
+
const bodyRef = useRef12(null);
|
|
7832
8328
|
const appHost = useMcpAppHost({
|
|
7833
8329
|
connection: mcpApps,
|
|
7834
8330
|
approve: agent.approveAppToolCall,
|
|
@@ -7840,7 +8336,7 @@ var AgentChatInner = ({
|
|
|
7840
8336
|
});
|
|
7841
8337
|
const prefersDark = usePrefersDark();
|
|
7842
8338
|
const appTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
|
|
7843
|
-
const [panelApp, setPanelAppState] =
|
|
8339
|
+
const [panelApp, setPanelAppState] = useState17();
|
|
7844
8340
|
const setPanelApp = (app) => {
|
|
7845
8341
|
setPanelAppState(app);
|
|
7846
8342
|
onAppPanel?.(app);
|
|
@@ -7854,14 +8350,14 @@ var AgentChatInner = ({
|
|
|
7854
8350
|
const panelAllowed = appPanel !== false && appPanel !== null;
|
|
7855
8351
|
const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
|
|
7856
8352
|
const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
|
|
7857
|
-
|
|
8353
|
+
useEffect17(() => {
|
|
7858
8354
|
if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
|
|
7859
8355
|
setPanelAppState(void 0);
|
|
7860
8356
|
onAppPanel?.(void 0);
|
|
7861
8357
|
}
|
|
7862
8358
|
}, [agent.messages, panelApp, onAppPanel]);
|
|
7863
8359
|
const drawApp = (app, message) => {
|
|
7864
|
-
const built = panelApp?.id === app.id ? /* @__PURE__ */
|
|
8360
|
+
const built = panelApp?.id === app.id ? /* @__PURE__ */ jsx20(
|
|
7865
8361
|
McpAppLine,
|
|
7866
8362
|
{
|
|
7867
8363
|
app,
|
|
@@ -7869,7 +8365,7 @@ var AgentChatInner = ({
|
|
|
7869
8365
|
action: L.appBringBack,
|
|
7870
8366
|
onAction: () => setPanelApp(void 0)
|
|
7871
8367
|
}
|
|
7872
|
-
) : /* @__PURE__ */
|
|
8368
|
+
) : /* @__PURE__ */ jsx20(
|
|
7873
8369
|
McpAppFrame,
|
|
7874
8370
|
{
|
|
7875
8371
|
app,
|
|
@@ -7882,7 +8378,7 @@ var AgentChatInner = ({
|
|
|
7882
8378
|
);
|
|
7883
8379
|
return renderApp ? renderApp(app, message, built) : built;
|
|
7884
8380
|
};
|
|
7885
|
-
const appPanelNode = appsOn && panelApp ? /* @__PURE__ */
|
|
8381
|
+
const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ jsx20(
|
|
7886
8382
|
McpAppFrame,
|
|
7887
8383
|
{
|
|
7888
8384
|
app: panelApp,
|
|
@@ -7894,7 +8390,7 @@ var AgentChatInner = ({
|
|
|
7894
8390
|
},
|
|
7895
8391
|
panelApp.id
|
|
7896
8392
|
) : null;
|
|
7897
|
-
const [compacting, setCompacting] =
|
|
8393
|
+
const [compacting, setCompacting] = useState17(false);
|
|
7898
8394
|
const compact = () => {
|
|
7899
8395
|
setCompacting(true);
|
|
7900
8396
|
void agent.compact().finally(() => setCompacting(false));
|
|
@@ -7905,9 +8401,10 @@ var AgentChatInner = ({
|
|
|
7905
8401
|
const Files = components.FilesPanel ?? FilesPanel;
|
|
7906
8402
|
const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
|
|
7907
8403
|
const Elicitations = components.ElicitationPrompt ?? ElicitationPrompt;
|
|
8404
|
+
const Questions = components.QuestionPrompt ?? QuestionPrompt;
|
|
7908
8405
|
const tabNotes = showOtherTabs ? [
|
|
7909
8406
|
agent.remote?.running && L.remoteRunning,
|
|
7910
|
-
agent.remote?.running && agent.approvals.some((a) => a.remote && a.status === "pending") && L.remoteWaitingConsent,
|
|
8407
|
+
agent.remote?.running && (agent.approvals.some((a) => a.remote && a.status === "pending") || (agent.questions ?? []).some((q) => q.remote && q.status === "pending")) && L.remoteWaitingConsent,
|
|
7911
8408
|
agent.remote?.ended === "gone" && L.remoteGone,
|
|
7912
8409
|
agent.sessionBusy && L.sessionBusy(agent.sessionBusy.heldBy)
|
|
7913
8410
|
].filter((t) => typeof t === "string") : [];
|
|
@@ -7915,18 +8412,18 @@ var AgentChatInner = ({
|
|
|
7915
8412
|
const showReplan = agent.replan && agent.replan.mode !== "continue";
|
|
7916
8413
|
const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
|
|
7917
8414
|
const earlyDecisions = showDecisions ? agent.decisions ?? [] : [];
|
|
7918
|
-
const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */
|
|
7919
|
-
agent.planThought.trim() && /* @__PURE__ */
|
|
7920
|
-
/* @__PURE__ */
|
|
7921
|
-
/* @__PURE__ */
|
|
8415
|
+
const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ jsxs19(Fragment11, { children: [
|
|
8416
|
+
agent.planThought.trim() && /* @__PURE__ */ jsxs19("details", { className: "awr-activity__plan", children: [
|
|
8417
|
+
/* @__PURE__ */ jsx20("summary", { children: L.planned }),
|
|
8418
|
+
/* @__PURE__ */ jsx20("p", { className: "awr-activity__thought", children: agent.planThought })
|
|
7922
8419
|
] }),
|
|
7923
|
-
showReplan && /* @__PURE__ */
|
|
7924
|
-
replanFailedEarly && /* @__PURE__ */
|
|
7925
|
-
/* @__PURE__ */
|
|
8420
|
+
showReplan && /* @__PURE__ */ jsx20("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
|
|
8421
|
+
replanFailedEarly && /* @__PURE__ */ jsxs19("p", { className: "awr-step__warn", title: agent.replan.error, children: [
|
|
8422
|
+
/* @__PURE__ */ jsx20(AlertIcon, { size: 12 }),
|
|
7926
8423
|
" ",
|
|
7927
8424
|
L.replanFailed
|
|
7928
8425
|
] }),
|
|
7929
|
-
earlyDecisions.map((d, i) => /* @__PURE__ */
|
|
8426
|
+
earlyDecisions.map((d, i) => /* @__PURE__ */ jsx20(
|
|
7930
8427
|
"p",
|
|
7931
8428
|
{
|
|
7932
8429
|
className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
|
|
@@ -7935,8 +8432,8 @@ var AgentChatInner = ({
|
|
|
7935
8432
|
i
|
|
7936
8433
|
))
|
|
7937
8434
|
] }) : void 0;
|
|
7938
|
-
const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */
|
|
7939
|
-
chats && /* @__PURE__ */
|
|
8435
|
+
const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__header", classNames.header), children: [
|
|
8436
|
+
chats && /* @__PURE__ */ jsx20(
|
|
7940
8437
|
"button",
|
|
7941
8438
|
{
|
|
7942
8439
|
type: "button",
|
|
@@ -7945,17 +8442,17 @@ var AgentChatInner = ({
|
|
|
7945
8442
|
title: L.showHistory,
|
|
7946
8443
|
"aria-pressed": historyOpen,
|
|
7947
8444
|
onClick: toggleHistory,
|
|
7948
|
-
children: /* @__PURE__ */
|
|
8445
|
+
children: /* @__PURE__ */ jsx20(HistoryIcon, { size: 16 })
|
|
7949
8446
|
}
|
|
7950
8447
|
),
|
|
7951
8448
|
slots.headerStart,
|
|
7952
|
-
/* @__PURE__ */
|
|
7953
|
-
showStatus && /* @__PURE__ */
|
|
7954
|
-
/* @__PURE__ */
|
|
7955
|
-
/* @__PURE__ */
|
|
8449
|
+
/* @__PURE__ */ jsx20("div", { className: "awr-chat__title", children: title }),
|
|
8450
|
+
showStatus && /* @__PURE__ */ jsxs19("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
|
|
8451
|
+
/* @__PURE__ */ jsx20("span", { className: "awr-status__dot" }),
|
|
8452
|
+
/* @__PURE__ */ jsx20("span", { className: "awr-status__text", children: L.status[agent.status] })
|
|
7956
8453
|
] }),
|
|
7957
|
-
showTotalUsage && /* @__PURE__ */
|
|
7958
|
-
files && /* @__PURE__ */
|
|
8454
|
+
showTotalUsage && /* @__PURE__ */ jsx20("span", { title: L.totalUsage, children: /* @__PURE__ */ jsx20(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
|
|
8455
|
+
files && /* @__PURE__ */ jsx20(
|
|
7959
8456
|
"button",
|
|
7960
8457
|
{
|
|
7961
8458
|
type: "button",
|
|
@@ -7964,12 +8461,12 @@ var AgentChatInner = ({
|
|
|
7964
8461
|
title: L.showFiles,
|
|
7965
8462
|
"aria-pressed": filesOpen,
|
|
7966
8463
|
onClick: toggleFiles,
|
|
7967
|
-
children: /* @__PURE__ */
|
|
8464
|
+
children: /* @__PURE__ */ jsx20(FileIcon, { size: 16 })
|
|
7968
8465
|
}
|
|
7969
8466
|
),
|
|
7970
8467
|
slots.headerEnd
|
|
7971
8468
|
] });
|
|
7972
|
-
return /* @__PURE__ */
|
|
8469
|
+
return /* @__PURE__ */ jsxs19(
|
|
7973
8470
|
"div",
|
|
7974
8471
|
{
|
|
7975
8472
|
ref: rootRef,
|
|
@@ -7977,7 +8474,7 @@ var AgentChatInner = ({
|
|
|
7977
8474
|
style,
|
|
7978
8475
|
"data-awr-theme": theme === "auto" ? void 0 : theme,
|
|
7979
8476
|
children: [
|
|
7980
|
-
overlayOpen && /* @__PURE__ */
|
|
8477
|
+
overlayOpen && /* @__PURE__ */ jsx20(
|
|
7981
8478
|
"div",
|
|
7982
8479
|
{
|
|
7983
8480
|
className: cx("awr-chat__scrim", classNames.scrim),
|
|
@@ -7985,8 +8482,8 @@ var AgentChatInner = ({
|
|
|
7985
8482
|
onClick: closeOverlays
|
|
7986
8483
|
}
|
|
7987
8484
|
),
|
|
7988
|
-
chats && historyOpen && /* @__PURE__ */
|
|
7989
|
-
/* @__PURE__ */
|
|
8485
|
+
chats && historyOpen && /* @__PURE__ */ jsxs19("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
|
|
8486
|
+
/* @__PURE__ */ jsx20(
|
|
7990
8487
|
HistoryList,
|
|
7991
8488
|
{
|
|
7992
8489
|
history: {
|
|
@@ -8005,7 +8502,7 @@ var AgentChatInner = ({
|
|
|
8005
8502
|
}
|
|
8006
8503
|
),
|
|
8007
8504
|
slots.sidebar,
|
|
8008
|
-
/* @__PURE__ */
|
|
8505
|
+
/* @__PURE__ */ jsx20(
|
|
8009
8506
|
"button",
|
|
8010
8507
|
{
|
|
8011
8508
|
type: "button",
|
|
@@ -8016,11 +8513,11 @@ var AgentChatInner = ({
|
|
|
8016
8513
|
}
|
|
8017
8514
|
)
|
|
8018
8515
|
] }),
|
|
8019
|
-
/* @__PURE__ */
|
|
8516
|
+
/* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__main", classNames.main), children: [
|
|
8020
8517
|
header,
|
|
8021
|
-
/* @__PURE__ */
|
|
8518
|
+
/* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
|
|
8022
8519
|
slots.beforeMessages,
|
|
8023
|
-
/* @__PURE__ */
|
|
8520
|
+
/* @__PURE__ */ jsx20(
|
|
8024
8521
|
Messages,
|
|
8025
8522
|
{
|
|
8026
8523
|
messages: agent.messages,
|
|
@@ -8058,7 +8555,7 @@ var AgentChatInner = ({
|
|
|
8058
8555
|
renderImageViewer
|
|
8059
8556
|
}
|
|
8060
8557
|
),
|
|
8061
|
-
/* @__PURE__ */
|
|
8558
|
+
/* @__PURE__ */ jsx20(
|
|
8062
8559
|
Approvals,
|
|
8063
8560
|
{
|
|
8064
8561
|
approvals: agent.pendingApprovals,
|
|
@@ -8068,7 +8565,16 @@ var AgentChatInner = ({
|
|
|
8068
8565
|
renderApproval
|
|
8069
8566
|
}
|
|
8070
8567
|
),
|
|
8071
|
-
|
|
8568
|
+
showQuestions && /* @__PURE__ */ jsx20(
|
|
8569
|
+
Questions,
|
|
8570
|
+
{
|
|
8571
|
+
questions: agent.pendingQuestions ?? [],
|
|
8572
|
+
onAnswer: (id, answer) => agent.answerQuestion?.(id, answer),
|
|
8573
|
+
outcomes: agent.questions,
|
|
8574
|
+
renderQuestion
|
|
8575
|
+
}
|
|
8576
|
+
),
|
|
8577
|
+
appsOn && /* @__PURE__ */ jsx20(
|
|
8072
8578
|
AppRequestPrompt,
|
|
8073
8579
|
{
|
|
8074
8580
|
requests: appHost.requests,
|
|
@@ -8076,7 +8582,7 @@ var AgentChatInner = ({
|
|
|
8076
8582
|
renderRequest: renderAppRequest
|
|
8077
8583
|
}
|
|
8078
8584
|
),
|
|
8079
|
-
showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */
|
|
8585
|
+
showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ jsx20(
|
|
8080
8586
|
Elicitations,
|
|
8081
8587
|
{
|
|
8082
8588
|
elicitations,
|
|
@@ -8085,13 +8591,13 @@ var AgentChatInner = ({
|
|
|
8085
8591
|
renderElicitation
|
|
8086
8592
|
}
|
|
8087
8593
|
),
|
|
8088
|
-
agent.modelLoad && loading && /* @__PURE__ */
|
|
8594
|
+
agent.modelLoad && loading && /* @__PURE__ */ jsx20(ModelLoadBar, { load: agent.modelLoad }),
|
|
8089
8595
|
slots.afterMessages
|
|
8090
8596
|
] }),
|
|
8091
|
-
/* @__PURE__ */
|
|
8597
|
+
/* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__footer", classNames.footer), children: [
|
|
8092
8598
|
slots.footerStart,
|
|
8093
|
-
tabNotes.length > 0 && /* @__PURE__ */
|
|
8094
|
-
showContext !== false && /* @__PURE__ */
|
|
8599
|
+
tabNotes.length > 0 && /* @__PURE__ */ jsx20("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text) => /* @__PURE__ */ jsx20("p", { className: "awr-tabnote__text", children: text }, text)) }),
|
|
8600
|
+
showContext !== false && /* @__PURE__ */ jsx20(
|
|
8095
8601
|
ContextMeter,
|
|
8096
8602
|
{
|
|
8097
8603
|
usage: agent.usage,
|
|
@@ -8102,11 +8608,11 @@ var AgentChatInner = ({
|
|
|
8102
8608
|
compacting
|
|
8103
8609
|
}
|
|
8104
8610
|
),
|
|
8105
|
-
composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */
|
|
8106
|
-
/* @__PURE__ */
|
|
8611
|
+
composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ jsxs19("div", { className: "awr-chat__error", children: [
|
|
8612
|
+
/* @__PURE__ */ jsx20(AlertIcon, { size: 14 }),
|
|
8107
8613
|
" ",
|
|
8108
8614
|
agent.error
|
|
8109
|
-
] }) : /* @__PURE__ */
|
|
8615
|
+
] }) : /* @__PURE__ */ jsx20(
|
|
8110
8616
|
Composer2,
|
|
8111
8617
|
{
|
|
8112
8618
|
controller: agent,
|
|
@@ -8123,7 +8629,7 @@ var AgentChatInner = ({
|
|
|
8123
8629
|
appPanelNode && (panelTarget ? (
|
|
8124
8630
|
// Outside the chat: the theme tokens come with it.
|
|
8125
8631
|
createPortal2(
|
|
8126
|
-
/* @__PURE__ */
|
|
8632
|
+
/* @__PURE__ */ jsx20(
|
|
8127
8633
|
"div",
|
|
8128
8634
|
{
|
|
8129
8635
|
className: "awr-theme awr-apppanel",
|
|
@@ -8133,24 +8639,24 @@ var AgentChatInner = ({
|
|
|
8133
8639
|
),
|
|
8134
8640
|
panelTarget
|
|
8135
8641
|
)
|
|
8136
|
-
) : asSheet ? /* @__PURE__ */
|
|
8137
|
-
/* @__PURE__ */
|
|
8138
|
-
/* @__PURE__ */
|
|
8642
|
+
) : asSheet ? /* @__PURE__ */ jsxs19(Fragment11, { children: [
|
|
8643
|
+
/* @__PURE__ */ jsx20("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
|
|
8644
|
+
/* @__PURE__ */ jsxs19(
|
|
8139
8645
|
"aside",
|
|
8140
8646
|
{
|
|
8141
8647
|
className: "awr-chat__appsheet",
|
|
8142
8648
|
role: "dialog",
|
|
8143
8649
|
"aria-label": L.appFrom(panelApp.server),
|
|
8144
8650
|
children: [
|
|
8145
|
-
/* @__PURE__ */
|
|
8651
|
+
/* @__PURE__ */ jsx20("div", { className: "awr-sheet__grab" }),
|
|
8146
8652
|
appPanelNode
|
|
8147
8653
|
]
|
|
8148
8654
|
}
|
|
8149
8655
|
)
|
|
8150
|
-
] }) : /* @__PURE__ */
|
|
8151
|
-
files && filesOpen && /* @__PURE__ */
|
|
8152
|
-
/* @__PURE__ */
|
|
8153
|
-
/* @__PURE__ */
|
|
8656
|
+
] }) : /* @__PURE__ */ jsx20("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
|
|
8657
|
+
files && filesOpen && /* @__PURE__ */ jsxs19("aside", { className: cx("awr-chat__files", classNames.files), children: [
|
|
8658
|
+
/* @__PURE__ */ jsx20(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ jsx20(Files, { files }) }),
|
|
8659
|
+
/* @__PURE__ */ jsx20(
|
|
8154
8660
|
"button",
|
|
8155
8661
|
{
|
|
8156
8662
|
type: "button",
|
|
@@ -8167,7 +8673,7 @@ var AgentChatInner = ({
|
|
|
8167
8673
|
};
|
|
8168
8674
|
|
|
8169
8675
|
// src/components/LearnedSkills.tsx
|
|
8170
|
-
import { jsx as
|
|
8676
|
+
import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
8171
8677
|
var LearnedSkills = ({
|
|
8172
8678
|
controller,
|
|
8173
8679
|
lessons,
|
|
@@ -8183,18 +8689,18 @@ var LearnedSkills = ({
|
|
|
8183
8689
|
const c = controller ?? ctx;
|
|
8184
8690
|
const list = lessons ?? c?.learned ?? [];
|
|
8185
8691
|
const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
|
|
8186
|
-
return /* @__PURE__ */
|
|
8187
|
-
!hideTitle && /* @__PURE__ */
|
|
8188
|
-
/* @__PURE__ */
|
|
8692
|
+
return /* @__PURE__ */ jsxs20("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
|
|
8693
|
+
!hideTitle && /* @__PURE__ */ jsxs20("h3", { className: "awr-notebook__title", children: [
|
|
8694
|
+
/* @__PURE__ */ jsx21(BookIcon, { size: 14 }),
|
|
8189
8695
|
" ",
|
|
8190
8696
|
L.notebookTitle,
|
|
8191
|
-
list.length > 0 && /* @__PURE__ */
|
|
8697
|
+
list.length > 0 && /* @__PURE__ */ jsx21("span", { className: "awr-notebook__count", children: list.length })
|
|
8192
8698
|
] }),
|
|
8193
|
-
list.length === 0 ? /* @__PURE__ */
|
|
8194
|
-
/* @__PURE__ */
|
|
8195
|
-
/* @__PURE__ */
|
|
8196
|
-
l.revision > 1 && /* @__PURE__ */
|
|
8197
|
-
forget && /* @__PURE__ */
|
|
8699
|
+
list.length === 0 ? /* @__PURE__ */ jsx21("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ jsx21("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ jsxs20("li", { className: "awr-lesson", children: [
|
|
8700
|
+
/* @__PURE__ */ jsxs20("div", { className: "awr-lesson__head", children: [
|
|
8701
|
+
/* @__PURE__ */ jsx21("code", { className: "awr-lesson__name", children: l.name }),
|
|
8702
|
+
l.revision > 1 && /* @__PURE__ */ jsx21("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
|
|
8703
|
+
forget && /* @__PURE__ */ jsx21(
|
|
8198
8704
|
"button",
|
|
8199
8705
|
{
|
|
8200
8706
|
type: "button",
|
|
@@ -8202,12 +8708,12 @@ var LearnedSkills = ({
|
|
|
8202
8708
|
title: `${L.notebookForget}: ${l.name}`,
|
|
8203
8709
|
"aria-label": `${L.notebookForget}: ${l.name}`,
|
|
8204
8710
|
onClick: () => void forget(l.name),
|
|
8205
|
-
children: /* @__PURE__ */
|
|
8711
|
+
children: /* @__PURE__ */ jsx21(XIcon, { size: 12 })
|
|
8206
8712
|
}
|
|
8207
8713
|
)
|
|
8208
8714
|
] }),
|
|
8209
|
-
/* @__PURE__ */
|
|
8210
|
-
showSources && l.sources.length > 0 && /* @__PURE__ */
|
|
8715
|
+
/* @__PURE__ */ jsx21("p", { className: "awr-lesson__when", children: l.description }),
|
|
8716
|
+
showSources && l.sources.length > 0 && /* @__PURE__ */ jsxs20("p", { className: "awr-lesson__from", children: [
|
|
8211
8717
|
L.notebookFrom,
|
|
8212
8718
|
" ",
|
|
8213
8719
|
l.sources.join(", ")
|
|
@@ -8217,8 +8723,8 @@ var LearnedSkills = ({
|
|
|
8217
8723
|
};
|
|
8218
8724
|
|
|
8219
8725
|
// src/components/Composer.tsx
|
|
8220
|
-
import { useState as
|
|
8221
|
-
import { jsx as
|
|
8726
|
+
import { useState as useState18 } from "react";
|
|
8727
|
+
import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
8222
8728
|
var Composer = ({
|
|
8223
8729
|
onSubmit,
|
|
8224
8730
|
busy = false,
|
|
@@ -8227,7 +8733,7 @@ var Composer = ({
|
|
|
8227
8733
|
placeholder = "Ask the agent to do something\u2026",
|
|
8228
8734
|
className
|
|
8229
8735
|
}) => {
|
|
8230
|
-
const [text, setText] =
|
|
8736
|
+
const [text, setText] = useState18("");
|
|
8231
8737
|
const submit = () => {
|
|
8232
8738
|
const value = text.trim();
|
|
8233
8739
|
if (!value || busy || disabled) return;
|
|
@@ -8240,7 +8746,7 @@ var Composer = ({
|
|
|
8240
8746
|
submit();
|
|
8241
8747
|
}
|
|
8242
8748
|
};
|
|
8243
|
-
return /* @__PURE__ */
|
|
8749
|
+
return /* @__PURE__ */ jsxs21(
|
|
8244
8750
|
"form",
|
|
8245
8751
|
{
|
|
8246
8752
|
className: ["awr-composer", className].filter(Boolean).join(" "),
|
|
@@ -8249,7 +8755,7 @@ var Composer = ({
|
|
|
8249
8755
|
submit();
|
|
8250
8756
|
},
|
|
8251
8757
|
children: [
|
|
8252
|
-
/* @__PURE__ */
|
|
8758
|
+
/* @__PURE__ */ jsx22(
|
|
8253
8759
|
"textarea",
|
|
8254
8760
|
{
|
|
8255
8761
|
className: "awr-composer__input",
|
|
@@ -8261,23 +8767,23 @@ var Composer = ({
|
|
|
8261
8767
|
rows: 1
|
|
8262
8768
|
}
|
|
8263
8769
|
),
|
|
8264
|
-
busy ? /* @__PURE__ */
|
|
8770
|
+
busy ? /* @__PURE__ */ jsx22(
|
|
8265
8771
|
"button",
|
|
8266
8772
|
{
|
|
8267
8773
|
type: "button",
|
|
8268
8774
|
className: "awr-composer__btn awr-composer__btn--stop",
|
|
8269
8775
|
onClick: onStop,
|
|
8270
8776
|
"aria-label": "Stop",
|
|
8271
|
-
children: /* @__PURE__ */
|
|
8777
|
+
children: /* @__PURE__ */ jsx22(StopIcon, { size: 18 })
|
|
8272
8778
|
}
|
|
8273
|
-
) : /* @__PURE__ */
|
|
8779
|
+
) : /* @__PURE__ */ jsx22(
|
|
8274
8780
|
"button",
|
|
8275
8781
|
{
|
|
8276
8782
|
type: "submit",
|
|
8277
8783
|
className: "awr-composer__btn",
|
|
8278
8784
|
disabled: disabled || !text.trim(),
|
|
8279
8785
|
"aria-label": "Send",
|
|
8280
|
-
children: disabled ? /* @__PURE__ */
|
|
8786
|
+
children: disabled ? /* @__PURE__ */ jsx22(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx22(SendIcon, { size: 18 })
|
|
8281
8787
|
}
|
|
8282
8788
|
)
|
|
8283
8789
|
]
|
|
@@ -8286,17 +8792,17 @@ var Composer = ({
|
|
|
8286
8792
|
};
|
|
8287
8793
|
|
|
8288
8794
|
// src/components/PlanView.tsx
|
|
8289
|
-
import { jsx as
|
|
8795
|
+
import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
8290
8796
|
var PlanView = ({ plan, showThought = true, className }) => {
|
|
8291
8797
|
if (!plan.steps.length && !plan.thought) return null;
|
|
8292
|
-
return /* @__PURE__ */
|
|
8293
|
-
showThought && plan.thought.trim() && /* @__PURE__ */
|
|
8294
|
-
plan.steps.length > 0 && /* @__PURE__ */
|
|
8798
|
+
return /* @__PURE__ */ jsxs22("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
|
|
8799
|
+
showThought && plan.thought.trim() && /* @__PURE__ */ jsx23("p", { className: "awr-plan__thought", children: plan.thought }),
|
|
8800
|
+
plan.steps.length > 0 && /* @__PURE__ */ jsx23("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx23("li", { className: "awr-plan__step", children: step.description }, step.id)) })
|
|
8295
8801
|
] });
|
|
8296
8802
|
};
|
|
8297
8803
|
|
|
8298
8804
|
// src/components/ApprovalModeSwitch.tsx
|
|
8299
|
-
import { jsx as
|
|
8805
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
8300
8806
|
var DEFAULT_LABELS = {
|
|
8301
8807
|
autopilot: "Autopilot",
|
|
8302
8808
|
"ask-writes": "Ask before changes",
|
|
@@ -8316,13 +8822,13 @@ var ApprovalModeSwitch = ({
|
|
|
8316
8822
|
labels,
|
|
8317
8823
|
disabled,
|
|
8318
8824
|
className
|
|
8319
|
-
}) => /* @__PURE__ */
|
|
8825
|
+
}) => /* @__PURE__ */ jsx24(
|
|
8320
8826
|
"div",
|
|
8321
8827
|
{
|
|
8322
8828
|
className: ["awr-modeswitch", className].filter(Boolean).join(" "),
|
|
8323
8829
|
role: "radiogroup",
|
|
8324
8830
|
"aria-label": "Tool consent",
|
|
8325
|
-
children: modes.map((m) => /* @__PURE__ */
|
|
8831
|
+
children: modes.map((m) => /* @__PURE__ */ jsx24(
|
|
8326
8832
|
"button",
|
|
8327
8833
|
{
|
|
8328
8834
|
type: "button",
|
|
@@ -8340,8 +8846,8 @@ var ApprovalModeSwitch = ({
|
|
|
8340
8846
|
);
|
|
8341
8847
|
|
|
8342
8848
|
// src/components/ApiKeyForm.tsx
|
|
8343
|
-
import { useEffect as
|
|
8344
|
-
import { jsx as
|
|
8849
|
+
import { useEffect as useEffect18, useState as useState19 } from "react";
|
|
8850
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8345
8851
|
var ApiKeyForm = ({
|
|
8346
8852
|
credentials,
|
|
8347
8853
|
credentialRef,
|
|
@@ -8350,10 +8856,10 @@ var ApiKeyForm = ({
|
|
|
8350
8856
|
onChange,
|
|
8351
8857
|
className
|
|
8352
8858
|
}) => {
|
|
8353
|
-
const [value, setValue] =
|
|
8354
|
-
const [present, setPresent] =
|
|
8355
|
-
const [busy, setBusy] =
|
|
8356
|
-
|
|
8859
|
+
const [value, setValue] = useState19("");
|
|
8860
|
+
const [present, setPresent] = useState19(false);
|
|
8861
|
+
const [busy, setBusy] = useState19(false);
|
|
8862
|
+
useEffect18(() => {
|
|
8357
8863
|
let active = true;
|
|
8358
8864
|
credentials.hasKey(credentialRef).then((has) => {
|
|
8359
8865
|
if (active) setPresent(has);
|
|
@@ -8385,16 +8891,16 @@ var ApiKeyForm = ({
|
|
|
8385
8891
|
setBusy(false);
|
|
8386
8892
|
}
|
|
8387
8893
|
};
|
|
8388
|
-
return /* @__PURE__ */
|
|
8389
|
-
/* @__PURE__ */
|
|
8894
|
+
return /* @__PURE__ */ jsxs23("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
|
|
8895
|
+
/* @__PURE__ */ jsxs23("label", { className: "awr-keyform__label", children: [
|
|
8390
8896
|
label,
|
|
8391
|
-
present && /* @__PURE__ */
|
|
8392
|
-
/* @__PURE__ */
|
|
8897
|
+
present && /* @__PURE__ */ jsxs23("span", { className: "awr-keyform__saved", children: [
|
|
8898
|
+
/* @__PURE__ */ jsx25(CheckIcon, { size: 12 }),
|
|
8393
8899
|
" stored, encrypted"
|
|
8394
8900
|
] })
|
|
8395
8901
|
] }),
|
|
8396
|
-
/* @__PURE__ */
|
|
8397
|
-
/* @__PURE__ */
|
|
8902
|
+
/* @__PURE__ */ jsxs23("div", { className: "awr-keyform__row", children: [
|
|
8903
|
+
/* @__PURE__ */ jsx25(
|
|
8398
8904
|
"input",
|
|
8399
8905
|
{
|
|
8400
8906
|
className: "awr-keyform__input",
|
|
@@ -8412,7 +8918,7 @@ var ApiKeyForm = ({
|
|
|
8412
8918
|
disabled: busy
|
|
8413
8919
|
}
|
|
8414
8920
|
),
|
|
8415
|
-
/* @__PURE__ */
|
|
8921
|
+
/* @__PURE__ */ jsx25(
|
|
8416
8922
|
"button",
|
|
8417
8923
|
{
|
|
8418
8924
|
type: "button",
|
|
@@ -8422,7 +8928,7 @@ var ApiKeyForm = ({
|
|
|
8422
8928
|
children: "Save"
|
|
8423
8929
|
}
|
|
8424
8930
|
),
|
|
8425
|
-
present && /* @__PURE__ */
|
|
8931
|
+
present && /* @__PURE__ */ jsx25(
|
|
8426
8932
|
"button",
|
|
8427
8933
|
{
|
|
8428
8934
|
type: "button",
|
|
@@ -8472,6 +8978,7 @@ export {
|
|
|
8472
8978
|
APP_DEFAULT_HEIGHT,
|
|
8473
8979
|
APP_MAX_HEIGHT,
|
|
8474
8980
|
APP_MIN_HEIGHT,
|
|
8981
|
+
ASK_USER_TOOL_NAME,
|
|
8475
8982
|
AgentChat,
|
|
8476
8983
|
AgentComposer,
|
|
8477
8984
|
AgentLabelsProvider,
|
|
@@ -8535,6 +9042,8 @@ export {
|
|
|
8535
9042
|
MessageList,
|
|
8536
9043
|
ModelLoadBar,
|
|
8537
9044
|
PlanView,
|
|
9045
|
+
QUESTION_TIMEOUT_MS,
|
|
9046
|
+
QuestionPrompt,
|
|
8538
9047
|
SandboxedFrame,
|
|
8539
9048
|
SessionBusyError,
|
|
8540
9049
|
SourceView,
|
|
@@ -8561,6 +9070,8 @@ export {
|
|
|
8561
9070
|
appMessageTextOf,
|
|
8562
9071
|
appMimeTypeOf,
|
|
8563
9072
|
appSamplingErrorOf,
|
|
9073
|
+
askUserOutputKept,
|
|
9074
|
+
askUserWith,
|
|
8564
9075
|
attachmentKindOf,
|
|
8565
9076
|
attachmentRefusal,
|
|
8566
9077
|
buildMcpAppDocument,
|
|
@@ -8573,6 +9084,7 @@ export {
|
|
|
8573
9084
|
createApprovalQueue,
|
|
8574
9085
|
createFileTools,
|
|
8575
9086
|
createInitialAgentState,
|
|
9087
|
+
createQuestionQueue,
|
|
8576
9088
|
createRunControl2 as createRunControl,
|
|
8577
9089
|
createSubagentTool,
|
|
8578
9090
|
createWebLLMEngine,
|
|
@@ -8619,6 +9131,9 @@ export {
|
|
|
8619
9131
|
pendingApprovalsOf,
|
|
8620
9132
|
postStorageChange2 as postStorageChange,
|
|
8621
9133
|
preloadWebLLMModel2 as preloadWebLLMModel,
|
|
9134
|
+
questionChoiceOf,
|
|
9135
|
+
questionOtherOf,
|
|
9136
|
+
questionTimeoutOf,
|
|
8622
9137
|
resolveAppDownload,
|
|
8623
9138
|
sandboxTokens,
|
|
8624
9139
|
sandboxedCsp,
|
|
@@ -8649,6 +9164,7 @@ export {
|
|
|
8649
9164
|
webSearchOf,
|
|
8650
9165
|
withAttachments,
|
|
8651
9166
|
withCspFirst,
|
|
8652
|
-
withPolicyFirst
|
|
9167
|
+
withPolicyFirst,
|
|
9168
|
+
withoutOwnWords
|
|
8653
9169
|
};
|
|
8654
9170
|
//# sourceMappingURL=index.js.map
|