@tangle-network/agent-app 0.50.9 → 0.50.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant/index.js +1 -1
- package/dist/chat-routes/index.js +3 -3
- package/dist/{chunk-DPO7FGCN.js → chunk-53K4S3K6.js} +1 -1
- package/dist/chunk-53K4S3K6.js.map +1 -0
- package/dist/{chunk-XZPJ3VM4.js → chunk-O2UKPZRF.js} +153 -121
- package/dist/chunk-O2UKPZRF.js.map +1 -0
- package/dist/{chunk-ZSSCVT6H.js → chunk-WWFE5EXY.js} +49 -78
- package/dist/chunk-WWFE5EXY.js.map +1 -0
- package/dist/{chunk-3MIQCPUX.js → chunk-XFCKMBOC.js} +3 -3
- package/dist/interactions/index.js +1 -1
- package/dist/interactions/sidecar.d.ts +3 -3
- package/dist/public-consultation/index.js +3 -3
- package/dist/stream/index.js +1 -1
- package/dist/stream/turn-identity.d.ts +3 -0
- package/dist/web-react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-DPO7FGCN.js.map +0 -1
- package/dist/chunk-XZPJ3VM4.js.map +0 -1
- package/dist/chunk-ZSSCVT6H.js.map +0 -1
- /package/dist/{chunk-3MIQCPUX.js.map → chunk-XFCKMBOC.js.map} +0 -0
package/dist/assistant/index.js
CHANGED
|
@@ -62,10 +62,10 @@ import {
|
|
|
62
62
|
rowIdOf,
|
|
63
63
|
storeSupportsDraftPersistence,
|
|
64
64
|
streamChatRouteAsSandboxEvents
|
|
65
|
-
} from "../chunk-
|
|
65
|
+
} from "../chunk-XFCKMBOC.js";
|
|
66
66
|
import "../chunk-TZEEGDHS.js";
|
|
67
67
|
import "../chunk-3NCPXNBZ.js";
|
|
68
|
-
import "../chunk-
|
|
68
|
+
import "../chunk-WWFE5EXY.js";
|
|
69
69
|
import {
|
|
70
70
|
attachmentInputToPart,
|
|
71
71
|
attachmentKindForMime,
|
|
@@ -96,7 +96,7 @@ import "../chunk-ZVEEWGDK.js";
|
|
|
96
96
|
import {
|
|
97
97
|
isWorkspaceFileExportable
|
|
98
98
|
} from "../chunk-TXD5HXLE.js";
|
|
99
|
-
import "../chunk-
|
|
99
|
+
import "../chunk-53K4S3K6.js";
|
|
100
100
|
import {
|
|
101
101
|
asRecord,
|
|
102
102
|
asString,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stream/turn-identity.ts","../src/stream/turn-observation.ts"],"sourcesContent":["import type { JsonRecord } from './stream-normalizer'\n\n/** Minimum read-only shape; typed chat parts need no dictionary index signature. */\ninterface TurnIdentityMessage {\n readonly id: string\n readonly role: 'user' | 'assistant' | 'system' | 'tool'\n readonly content: string\n readonly parts: readonly object[] | null\n}\n\n/** Retained compatibility shape for callers using unstructured message records. */\nexport interface PersistedChatMessageForTurn extends TurnIdentityMessage {\n id: string\n role: TurnIdentityMessage['role']\n content: string\n parts: Array<Record<string, unknown>> | null\n}\n\n/** Represent a chat turn with resolved user message insertion and prior message context */\nexport interface ResolvedChatTurn<Message extends TurnIdentityMessage = PersistedChatMessageForTurn> {\n turnIndex: number\n shouldInsertUserMessage: boolean\n priorMessages: Message[]\n userParts: JsonRecord[]\n /** The id of the user row this turn REUSES (retry dedup), when one was\n * found. Absent on the insert path, where no row exists yet.\n *\n * The reused row is deliberately EXCLUDED from `priorMessages` (it is this\n * turn's own user message, not prior context), so this field is the only\n * way a caller can name it. */\n reusedUserMessageId?: string\n}\n\n/** Normalize and validate a client turn ID string ensuring it meets format and length requirements */\nexport function normalizeClientTurnId(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined\n if (typeof value !== 'string') throw new Error('turnId must be a string')\n const trimmed = value.trim()\n if (!trimmed) throw new Error('turnId must not be blank')\n if (trimmed.length > 160) throw new Error('turnId is too long')\n if (!/^[A-Za-z0-9:_-]+$/.test(trimmed)) {\n throw new Error('turnId contains unsupported characters')\n }\n return trimmed\n}\n\n/** Build an array of text parts with optional turn ID for user input */\nexport function buildUserTextParts(text: string, turnId: string | undefined): JsonRecord[] {\n const part: JsonRecord = { type: 'text', text }\n if (turnId) part.turnId = turnId\n return [part]\n}\n\n/** Resolve whether a message contains any part with the specified turn ID */\nexport function messageHasTurnId(message: Pick<TurnIdentityMessage, 'parts'>, turnId: string): boolean {\n for (const part of message.parts ?? []) {\n if (part && typeof part === 'object' && 'turnId' in part && String(part.turnId ?? '') === turnId) {\n return true\n }\n }\n return false\n}\n\n/** Resolve a chat turn by determining message reuse and constructing user message parts */\nexport function resolveChatTurn<Message extends TurnIdentityMessage>(input: {\n existingMessages: readonly Message[]\n userContent: string\n turnId?: string\n /** True when the thread has a turn still RUNNING in the turn-event buffer\n * (`turnStore.listRunning(threadId)`).\n *\n * Without incremental persistence the trailing row of a thread mid-turn is\n * always the user row, so the content fallback below could assume it. With\n * incremental persistence the assistant row lands seconds into the turn, so\n * a retry of that same turn finds an ASSISTANT row trailing and would\n * insert a duplicate user row.\n *\n * This flag is the discriminator that keeps both cases right, and it needs\n * no new state: an assistant row trailing a turn that is still running is\n * that turn's in-flight draft (walk past it — this is a retry), whereas an\n * assistant row trailing a SETTLED turn is a completed answer (stop — the\n * user genuinely repeated a message and deserves a new turn). */\n hasRunningTurn?: boolean\n}): ResolvedChatTurn<Message> {\n const { existingMessages, userContent, turnId } = input\n const reusableIndex = findReusableUserMessageIndex(\n existingMessages,\n userContent,\n turnId,\n input.hasRunningTurn === true,\n )\n if (reusableIndex >= 0) {\n // Guarded read: `id` is typed `string`, but these rows come from a product\n // store the shell does not validate, so an adapter that omits it must\n // surface as \"no id\" rather than as the string \"undefined\".\n const reusedId = existingMessages[reusableIndex]?.id\n const priorMessages = existingMessages.slice(0, reusableIndex)\n return {\n turnIndex: countUserMessages(priorMessages),\n shouldInsertUserMessage: false,\n priorMessages,\n userParts: buildUserTextParts(userContent, turnId),\n ...(typeof reusedId === 'string' && reusedId ? { reusedUserMessageId: reusedId } : {}),\n }\n }\n\n return {\n turnIndex: countUserMessages(existingMessages),\n shouldInsertUserMessage: true,\n priorMessages: existingMessages.slice(),\n userParts: buildUserTextParts(userContent, turnId),\n }\n}\n\nfunction findReusableUserMessageIndex(\n messages: readonly TurnIdentityMessage[],\n userContent: string,\n turnId: string | undefined,\n hasRunningTurn: boolean,\n): number {\n if (turnId) {\n for (let index = messages.length - 1; index >= 0; index -= 1) {\n const message = messages[index]\n if (message?.role === 'user' && messageHasTurnId(message, turnId)) return index\n }\n // A caller-supplied id is authoritative. A different id with identical\n // text is a deliberate new turn, while a transport retry reuses the same\n // id and takes the match above. Falling through to content dedup here lets\n // an unrelated abandoned running row swallow an intentional repeat.\n return -1\n }\n\n // Content fallback for a client that sends no turnId. Only the trailing rows\n // of a turn still RUNNING are walked past (they are that turn's incrementally\n // persisted assistant draft); a settled assistant row still ends the scan, so\n // a user who genuinely repeats a message gets a new turn exactly as before.\n let index = messages.length - 1\n if (hasRunningTurn) {\n while (index >= 0 && messages[index]?.role === 'assistant') index -= 1\n }\n const latest = index >= 0 ? messages[index] : undefined\n if (latest?.role === 'user' && latest.content === userContent) return index\n\n return -1\n}\n\nfunction countUserMessages(messages: readonly TurnIdentityMessage[]): number {\n let count = 0\n for (const message of messages) if (message.role === 'user') count++\n return count\n}\n","/** Read-side checkpoints for native chat NDJSON. This never submits or cancels work. */\nexport interface TurnObservation {\n schema: 'turn-observation-v1'\n streamId: string | null\n /** Replay ordinals only. Unsequenced live frames cannot advance this cursor. */\n lastSeq: number\n outcome: 'completed' | 'failed' | null\n replayStatus: string | null\n eventCount: number\n}\n\nexport function parseTurnObservation(value?: unknown): TurnObservation {\n if (value === undefined) return {\n schema: 'turn-observation-v1', streamId: null, lastSeq: 0,\n outcome: null, replayStatus: null, eventCount: 0,\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError('Invalid turn observation')\n const v = value as Record<string, unknown>\n if (v.schema !== 'turn-observation-v1'\n || !(v.streamId === null || (typeof v.streamId === 'string' && /^[A-Za-z0-9_-]+$/.test(v.streamId)))\n || !Number.isSafeInteger(v.lastSeq) || Number(v.lastSeq) < 0\n || !Number.isSafeInteger(v.eventCount) || Number(v.eventCount) < 0\n || !(v.outcome === null || v.outcome === 'completed' || v.outcome === 'failed')\n || !(v.replayStatus === null || typeof v.replayStatus === 'string')\n || (v.streamId === null && Number(v.lastSeq) > 0)) throw new TypeError('Invalid turn observation')\n return {\n schema: 'turn-observation-v1', streamId: v.streamId as string | null,\n lastSeq: Number(v.lastSeq), outcome: v.outcome as TurnObservation['outcome'],\n replayStatus: v.replayStatus as string | null, eventCount: Number(v.eventCount),\n }\n}\n\nexport interface TurnObservationUpdate {\n checkpoint: TurnObservation\n /** False only for an already-checkpointed replay ordinal. */\n accepted: boolean\n event: Record<string, unknown>\n}\n\n/** Reduce an observed frame. Ordered replay gaps are errors, not silent lost work. */\nexport function observeTurnEvent(previous: TurnObservation, raw: unknown): TurnObservationUpdate {\n const checkpoint = parseTurnObservation(previous)\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new TypeError('Turn frame must be an object')\n const outer = raw as Record<string, unknown>\n const inner = outer.kind === 'event' ? outer.event : outer\n if (!inner || typeof inner !== 'object' || Array.isArray(inner)) throw new TypeError('Invalid turn event envelope')\n const event = inner as Record<string, unknown>\n if (typeof event.type !== 'string' || !event.type) throw new TypeError('Turn frame requires a type')\n\n // Even a duplicate marker must not switch which execution we are observing.\n if (event.type === 'turn') {\n if (typeof event.turnId !== 'string' || !/^[A-Za-z0-9_-]+$/.test(event.turnId)) throw new TypeError('Invalid stream identity')\n if (checkpoint.streamId !== null && checkpoint.streamId !== event.turnId) throw new Error('Replay stream identity changed')\n checkpoint.streamId = event.turnId\n }\n const seq = outer.seq\n if (seq !== undefined && seq !== -1) {\n if (!Number.isSafeInteger(seq) || Number(seq) < 1) throw new TypeError('Invalid replay ordinal')\n if (checkpoint.streamId === null) throw new Error('Replay ordinal arrived before stream identity')\n if (Number(seq) <= checkpoint.lastSeq) return { checkpoint, accepted: false, event }\n if (Number(seq) !== checkpoint.lastSeq + 1) throw new Error('Replay has a gap; retain the checkpoint and inspect durable history')\n checkpoint.lastSeq = Number(seq)\n } else if (seq === -1 && event.type !== 'turn_status') {\n throw new TypeError('Only a turn-status sentinel may have ordinal -1')\n }\n\n if (event.type === 'error' || event.type === 'session.run.failed') checkpoint.outcome = 'failed'\n if (event.type === 'session.run.completed' && checkpoint.outcome !== 'failed') checkpoint.outcome = 'completed'\n if (event.type === 'turn_status') {\n if (typeof event.status !== 'string') throw new TypeError('Turn status requires a value')\n checkpoint.replayStatus = event.status\n if (['error', 'failed', 'aborted', 'cancelled'].includes(event.status)) checkpoint.outcome = 'failed'\n if (['complete', 'completed'].includes(event.status) && checkpoint.outcome !== 'failed') checkpoint.outcome = 'completed'\n }\n checkpoint.eventCount += 1\n return { checkpoint, accepted: true, event }\n}\n\nexport interface ConsumeTurnStreamOptions {\n checkpoint?: TurnObservation\n /** Commit evidence and its checkpoint durably before acknowledging this frame. */\n commit(update: TurnObservationUpdate): Promise<void>\n /** Bound untrusted frame memory, not total run duration or total transcript size. */\n maxFrameBytes?: number\n}\n\n/**\n * Consume one viewing connection. EOF without a terminal event stays incomplete.\n * A disconnect/abort propagates; the last committed checkpoint remains resumable.\n * The caller owns network observation windows separately from execution deadlines.\n */\nexport async function consumeTurnStream(\n body: AsyncIterable<Uint8Array>,\n options: ConsumeTurnStreamOptions,\n): Promise<TurnObservation> {\n const maxFrameBytes = options.maxFrameBytes ?? 4 * 1024 * 1024\n if (!Number.isSafeInteger(maxFrameBytes) || maxFrameBytes < 1) throw new RangeError('Frame byte limit must be positive')\n let state = parseTurnObservation(options.checkpoint)\n const decoder = new TextDecoder('utf-8', { fatal: true })\n let pending = ''\n let frameBytes = 0\n async function accept(line: string): Promise<void> {\n if (!line.trim()) return\n const update = observeTurnEvent(state, JSON.parse(line))\n if (update.accepted) await options.commit(update)\n state = update.checkpoint\n }\n for await (const chunk of body) {\n // Count bytes before decoding: a malicious unterminated frame cannot grow\n // without bound, and splitting UTF-8 characters across chunks stays valid.\n let start = 0\n for (let end = 0; end < chunk.length; end += 1) {\n if (chunk[end] !== 10) continue\n frameBytes += end - start\n if (frameBytes > maxFrameBytes) throw new RangeError('Turn frame exceeds byte limit')\n pending += decoder.decode(chunk.subarray(start, end + 1), { stream: true })\n await accept(pending)\n pending = ''; frameBytes = 0; start = end + 1\n }\n frameBytes += chunk.length - start\n if (frameBytes > maxFrameBytes) throw new RangeError('Turn frame exceeds byte limit')\n pending += decoder.decode(chunk.subarray(start), { stream: true })\n }\n pending += decoder.decode()\n await accept(pending)\n return state\n}\n"],"mappings":";AAkCO,SAAS,sBAAsB,OAAoC;AACxE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI,OAAO,UAAU,SAAU,OAAM,IAAI,MAAM,yBAAyB;AACxE,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AACxD,MAAI,QAAQ,SAAS,IAAK,OAAM,IAAI,MAAM,oBAAoB;AAC9D,MAAI,CAAC,oBAAoB,KAAK,OAAO,GAAG;AACtC,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC1D;AACA,SAAO;AACT;AAGO,SAAS,mBAAmB,MAAc,QAA0C;AACzF,QAAM,OAAmB,EAAE,MAAM,QAAQ,KAAK;AAC9C,MAAI,OAAQ,MAAK,SAAS;AAC1B,SAAO,CAAC,IAAI;AACd;AAGO,SAAS,iBAAiB,SAA6C,QAAyB;AACrG,aAAW,QAAQ,QAAQ,SAAS,CAAC,GAAG;AACtC,QAAI,QAAQ,OAAO,SAAS,YAAY,YAAY,QAAQ,OAAO,KAAK,UAAU,EAAE,MAAM,QAAQ;AAChG,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,gBAAqD,OAmBvC;AAC5B,QAAM,EAAE,kBAAkB,aAAa,OAAO,IAAI;AAClD,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA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|
|
1419
1419
|
import { useEffect as useEffect5, useId, useState as useState7 } from "react";
|
|
1420
1420
|
import { agentProfileSchema } from "@tangle-network/agent-interface/profile-schema";
|
|
1421
|
+
import { Button, Input, Textarea, Switch, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@tangle-network/sandbox-ui/primitives";
|
|
1421
1422
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1422
|
-
var input = "min-h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50";
|
|
1423
|
-
var button = "rounded-lg border border-input bg-background px-3 py-2 text-sm font-medium text-foreground hover:bg-accent disabled:opacity-50";
|
|
1424
|
-
var remove = "text-destructive hover:underline disabled:opacity-50";
|
|
1425
1423
|
function Field({ label, hint, children }) {
|
|
1426
1424
|
return /* @__PURE__ */ jsxs5("label", { className: "block space-y-1.5 text-sm font-medium text-foreground", children: [
|
|
1427
1425
|
/* @__PURE__ */ jsx7("span", { children: label }),
|
|
@@ -1438,6 +1436,21 @@ function Section({ title, description, children }) {
|
|
|
1438
1436
|
children
|
|
1439
1437
|
] });
|
|
1440
1438
|
}
|
|
1439
|
+
function Disclosure({ title, description, detail, children }) {
|
|
1440
|
+
return /* @__PURE__ */ jsxs5("details", { className: "group rounded-xl border border-border bg-card", children: [
|
|
1441
|
+
/* @__PURE__ */ jsxs5("summary", { className: "flex cursor-pointer list-none items-center justify-between gap-4 rounded-xl p-4 marker:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:p-5", children: [
|
|
1442
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
1443
|
+
/* @__PURE__ */ jsx7("span", { className: "block text-base font-semibold text-foreground", children: title }),
|
|
1444
|
+
description && /* @__PURE__ */ jsx7("span", { className: "mt-1 block text-sm text-muted-foreground", children: description })
|
|
1445
|
+
] }),
|
|
1446
|
+
/* @__PURE__ */ jsxs5("span", { className: "flex shrink-0 items-center gap-2 text-sm text-muted-foreground", children: [
|
|
1447
|
+
detail,
|
|
1448
|
+
/* @__PURE__ */ jsx7("span", { "aria-hidden": "true", className: "transition-transform group-open:rotate-180", children: "\u2304" })
|
|
1449
|
+
] })
|
|
1450
|
+
] }),
|
|
1451
|
+
/* @__PURE__ */ jsx7("div", { className: "space-y-4 border-t border-border p-4 sm:p-5", children })
|
|
1452
|
+
] });
|
|
1453
|
+
}
|
|
1441
1454
|
function issueMessage(error) {
|
|
1442
1455
|
const issue = error.issues[0];
|
|
1443
1456
|
return issue ? (issue.path.map(String).join(".") || "Profile") + ": " + issue.message : "Invalid profile";
|
|
@@ -1446,6 +1459,7 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1446
1459
|
const id = useId();
|
|
1447
1460
|
const [error, setError] = useState7(null);
|
|
1448
1461
|
const [newTool, setNewTool] = useState7("");
|
|
1462
|
+
const [showAllTools, setShowAllTools] = useState7(false);
|
|
1449
1463
|
const [mcpName, setMcpName] = useState7("");
|
|
1450
1464
|
const [mcpKind, setMcpKind] = useState7("http");
|
|
1451
1465
|
const [mcpTarget, setMcpTarget] = useState7("");
|
|
@@ -1495,7 +1509,7 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1495
1509
|
function change(field, text) {
|
|
1496
1510
|
setResourceDrafts((current) => ({ ...current, [key]: { ...draft, [field]: text } }));
|
|
1497
1511
|
}
|
|
1498
|
-
return /* @__PURE__ */ jsxs5(
|
|
1512
|
+
return /* @__PURE__ */ jsxs5(Disclosure, { title, description, detail: refs.length ? refs.length + " added" : "Optional", children: [
|
|
1499
1513
|
refs.length === 0 && /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "None added." }),
|
|
1500
1514
|
/* @__PURE__ */ jsx7("ul", { className: "space-y-2", children: refs.map((ref, index) => /* @__PURE__ */ jsxs5("li", { className: "flex items-start justify-between gap-3 rounded-lg border border-border p-3 text-sm", children: [
|
|
1501
1515
|
/* @__PURE__ */ jsxs5("div", { className: "min-w-0", children: [
|
|
@@ -1504,10 +1518,11 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1504
1518
|
ref.kind === "github" && ref.repository && /* @__PURE__ */ jsx7("span", { className: "block text-xs text-muted-foreground", children: ref.repository })
|
|
1505
1519
|
] }),
|
|
1506
1520
|
/* @__PURE__ */ jsx7(
|
|
1507
|
-
|
|
1521
|
+
Button,
|
|
1508
1522
|
{
|
|
1509
1523
|
type: "button",
|
|
1510
|
-
|
|
1524
|
+
variant: "ghost",
|
|
1525
|
+
className: "text-destructive",
|
|
1511
1526
|
disabled: editingDisabled,
|
|
1512
1527
|
"aria-label": "Remove " + title.toLowerCase() + " " + (index + 1),
|
|
1513
1528
|
onClick: () => resources(key, refs.filter((_, item) => item !== index)),
|
|
@@ -1516,23 +1531,16 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1516
1531
|
)
|
|
1517
1532
|
] }, index)) }),
|
|
1518
1533
|
/* @__PURE__ */ jsxs5("div", { className: "grid gap-3 rounded-lg border border-dashed border-border p-3 sm:grid-cols-[10rem_1fr]", children: [
|
|
1519
|
-
/* @__PURE__ */ jsx7(Field, { label: "Source", children: /* @__PURE__ */ jsxs5(
|
|
1520
|
-
"
|
|
1521
|
-
{
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
children: [
|
|
1527
|
-
/* @__PURE__ */ jsx7("option", { value: "github", children: "GitHub path" }),
|
|
1528
|
-
/* @__PURE__ */ jsx7("option", { value: "inline", children: "Inline content" })
|
|
1529
|
-
]
|
|
1530
|
-
}
|
|
1531
|
-
) }),
|
|
1534
|
+
/* @__PURE__ */ jsx7(Field, { label: "Source", children: /* @__PURE__ */ jsxs5(Select, { disabled: editingDisabled, value: draft.kind, onValueChange: (kind) => change("kind", kind), children: [
|
|
1535
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { "aria-label": "Source", children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
1536
|
+
/* @__PURE__ */ jsxs5(SelectContent, { children: [
|
|
1537
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "github", children: "GitHub path" }),
|
|
1538
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "inline", children: "Inline content" })
|
|
1539
|
+
] })
|
|
1540
|
+
] }) }),
|
|
1532
1541
|
/* @__PURE__ */ jsx7(Field, { label: draft.kind === "github" ? "Path" : "Name", children: /* @__PURE__ */ jsx7(
|
|
1533
|
-
|
|
1542
|
+
Input,
|
|
1534
1543
|
{
|
|
1535
|
-
className: input,
|
|
1536
1544
|
disabled: editingDisabled,
|
|
1537
1545
|
value: draft.kind === "github" ? draft.path : draft.name,
|
|
1538
1546
|
onChange: (event) => change(draft.kind === "github" ? "path" : "name", event.target.value),
|
|
@@ -1540,15 +1548,15 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1540
1548
|
}
|
|
1541
1549
|
) }),
|
|
1542
1550
|
draft.kind === "inline" && /* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsx7(Field, { label: "Content", children: /* @__PURE__ */ jsx7(
|
|
1543
|
-
|
|
1551
|
+
Textarea,
|
|
1544
1552
|
{
|
|
1545
|
-
className:
|
|
1553
|
+
className: "min-h-28",
|
|
1546
1554
|
disabled: editingDisabled,
|
|
1547
1555
|
value: draft.content,
|
|
1548
1556
|
onChange: (event) => change("content", event.target.value)
|
|
1549
1557
|
}
|
|
1550
1558
|
) }) }),
|
|
1551
|
-
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsxs5(
|
|
1559
|
+
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsxs5(Button, { type: "button", variant: "outline", disabled: editingDisabled, onClick: () => addResource(key), children: [
|
|
1552
1560
|
"Add ",
|
|
1553
1561
|
key === "skills" ? "skill" : "tool file"
|
|
1554
1562
|
] }) })
|
|
@@ -1589,104 +1597,125 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1589
1597
|
}
|
|
1590
1598
|
return /* @__PURE__ */ jsxs5("div", { className: "space-y-5 " + (className ?? ""), "aria-label": "Agent profile editor", children: [
|
|
1591
1599
|
error && /* @__PURE__ */ jsx7("p", { role: "alert", className: "rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive", children: error }),
|
|
1592
|
-
/* @__PURE__ */
|
|
1600
|
+
jsonDirty && /* @__PURE__ */ jsx7("p", { role: "status", className: "rounded-lg border border-border bg-muted p-3 text-sm text-foreground", children: "Apply or discard edits in Advanced JSON before using the other fields." }),
|
|
1601
|
+
/* @__PURE__ */ jsxs5(Section, { title: "Profile", description: "Name the agent and set its instructions.", children: [
|
|
1593
1602
|
/* @__PURE__ */ jsxs5("div", { className: "grid gap-4 sm:grid-cols-2", children: [
|
|
1594
|
-
/* @__PURE__ */ jsx7(Field, { label: "Name", children: /* @__PURE__ */ jsx7(
|
|
1595
|
-
/* @__PURE__ */ jsx7(Field, { label: "Description", children: /* @__PURE__ */ jsx7(
|
|
1603
|
+
/* @__PURE__ */ jsx7(Field, { label: "Name", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: value.name ?? "", onChange: (event) => emit({ ...value, name: event.target.value }) }) }),
|
|
1604
|
+
/* @__PURE__ */ jsx7(Field, { label: "Description", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: value.description ?? "", onChange: (event) => emit({ ...value, description: event.target.value }) }) })
|
|
1596
1605
|
] }),
|
|
1597
|
-
/* @__PURE__ */
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1606
|
+
/* @__PURE__ */ jsxs5("div", { role: "group", "aria-label": "Agent instructions", className: "space-y-2", children: [
|
|
1607
|
+
/* @__PURE__ */ jsx7("p", { className: "text-sm font-medium text-foreground", children: "Agent instructions" }),
|
|
1608
|
+
/* @__PURE__ */ jsx7("p", { className: "text-xs text-muted-foreground", children: "Project-level instructions. Each entry remains separate." }),
|
|
1609
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
1610
|
+
(value.prompt?.instructions ?? []).map((instruction, index) => /* @__PURE__ */ jsxs5("div", { className: "flex items-start gap-2", children: [
|
|
1611
|
+
/* @__PURE__ */ jsx7(
|
|
1612
|
+
Textarea,
|
|
1613
|
+
{
|
|
1614
|
+
"aria-label": "Instruction " + (index + 1),
|
|
1615
|
+
className: "min-h-20",
|
|
1616
|
+
disabled: editingDisabled,
|
|
1617
|
+
value: instruction,
|
|
1618
|
+
onChange: (event) => prompt({ ...value.prompt, instructions: (value.prompt?.instructions ?? []).map((item, i) => i === index ? event.target.value : item) })
|
|
1619
|
+
}
|
|
1620
|
+
),
|
|
1621
|
+
/* @__PURE__ */ jsx7(
|
|
1622
|
+
Button,
|
|
1623
|
+
{
|
|
1624
|
+
type: "button",
|
|
1625
|
+
variant: "ghost",
|
|
1626
|
+
className: "pt-2 text-destructive",
|
|
1627
|
+
disabled: editingDisabled,
|
|
1628
|
+
"aria-label": "Remove instruction " + (index + 1),
|
|
1629
|
+
onClick: () => prompt({ ...value.prompt, instructions: (value.prompt?.instructions ?? []).filter((_, i) => i !== index) }),
|
|
1630
|
+
children: "Remove"
|
|
1631
|
+
}
|
|
1632
|
+
)
|
|
1633
|
+
] }, index)),
|
|
1634
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", disabled: editingDisabled, onClick: () => prompt({ ...value.prompt, instructions: [...value.prompt?.instructions ?? [], ""] }), children: "Add instruction" })
|
|
1635
|
+
] })
|
|
1636
|
+
] }),
|
|
1637
|
+
/* @__PURE__ */ jsxs5("details", { className: "rounded-lg border border-border p-3", children: [
|
|
1638
|
+
/* @__PURE__ */ jsx7("summary", { className: "cursor-pointer font-medium text-foreground", children: "System prompt overrides" }),
|
|
1639
|
+
/* @__PURE__ */ jsxs5("div", { className: "mt-4 space-y-4", children: [
|
|
1640
|
+
/* @__PURE__ */ jsx7(Field, { label: "Append to system prompt", hint: "Keeps the harness system prompt and adds this text.", children: /* @__PURE__ */ jsx7(Textarea, { className: "min-h-24", disabled: editingDisabled, value: value.prompt?.appendSystemPrompt ?? "", onChange: (event) => prompt({ ...value.prompt, appendSystemPrompt: event.target.value }) }) }),
|
|
1641
|
+
/* @__PURE__ */ jsx7(Field, { label: "Replace system prompt", hint: "Only use when the harness supports full replacement.", children: /* @__PURE__ */ jsx7(Textarea, { className: "min-h-24", disabled: editingDisabled, value: value.prompt?.systemPrompt ?? "", onChange: (event) => prompt({ ...value.prompt, systemPrompt: event.target.value }) }) })
|
|
1642
|
+
] })
|
|
1643
|
+
] })
|
|
1644
|
+
] }),
|
|
1645
|
+
/* @__PURE__ */ jsxs5(Section, { title: "Model", description: "Set model preferences. The host decides which models can run.", children: [
|
|
1646
|
+
/* @__PURE__ */ jsx7("div", { className: "grid gap-4 sm:grid-cols-2", children: /* @__PURE__ */ jsx7(Field, { label: "Default model", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: value.model?.default ?? "", onChange: (event) => model({ ...value.model, default: event.target.value }), placeholder: "provider/model" }) }) }),
|
|
1647
|
+
/* @__PURE__ */ jsxs5("details", { className: "rounded-lg border border-border p-3", children: [
|
|
1648
|
+
/* @__PURE__ */ jsx7("summary", { className: "cursor-pointer font-medium text-foreground", children: "More model settings" }),
|
|
1649
|
+
/* @__PURE__ */ jsxs5("div", { className: "mt-4 grid gap-4 sm:grid-cols-2", children: [
|
|
1650
|
+
/* @__PURE__ */ jsx7(Field, { label: "Small model", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: value.model?.small ?? "", onChange: (event) => model({ ...value.model, small: event.target.value }), placeholder: "provider/model" }) }),
|
|
1651
|
+
/* @__PURE__ */ jsx7(Field, { label: "Provider hint", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: value.model?.provider ?? "", onChange: (event) => model({ ...value.model, provider: event.target.value }) }) }),
|
|
1652
|
+
/* @__PURE__ */ jsx7(Field, { label: "Thinking level", children: /* @__PURE__ */ jsxs5(
|
|
1653
|
+
Select,
|
|
1610
1654
|
{
|
|
1611
|
-
type: "button",
|
|
1612
|
-
className: remove + " pt-2",
|
|
1613
1655
|
disabled: editingDisabled,
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
children:
|
|
1656
|
+
value: value.model?.reasoningEffort ?? "default",
|
|
1657
|
+
onValueChange: (level) => model({ ...value.model, reasoningEffort: level === "default" ? void 0 : level }),
|
|
1658
|
+
children: [
|
|
1659
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { "aria-label": "Thinking level", children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
1660
|
+
/* @__PURE__ */ jsxs5(SelectContent, { children: [
|
|
1661
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "default", children: "Harness default" }),
|
|
1662
|
+
["none", "minimal", "low", "medium", "high", "xhigh", "ultracode"].map((level) => /* @__PURE__ */ jsx7(SelectItem, { value: level, children: level }, level))
|
|
1663
|
+
] })
|
|
1664
|
+
]
|
|
1617
1665
|
}
|
|
1618
|
-
)
|
|
1619
|
-
] }
|
|
1620
|
-
|
|
1621
|
-
] }) }),
|
|
1622
|
-
/* @__PURE__ */ jsx7(Field, { label: "Append to system prompt", hint: "Keeps the harness system prompt and adds this text.", children: /* @__PURE__ */ jsx7("textarea", { className: input + " min-h-24", disabled: editingDisabled, value: value.prompt?.appendSystemPrompt ?? "", onChange: (event) => prompt({ ...value.prompt, appendSystemPrompt: event.target.value }) }) }),
|
|
1623
|
-
/* @__PURE__ */ jsx7(Field, { label: "Replace system prompt", hint: "Only use when the harness supports full replacement.", children: /* @__PURE__ */ jsx7("textarea", { className: input + " min-h-24", disabled: editingDisabled, value: value.prompt?.systemPrompt ?? "", onChange: (event) => prompt({ ...value.prompt, systemPrompt: event.target.value }) }) })
|
|
1666
|
+
) })
|
|
1667
|
+
] })
|
|
1668
|
+
] })
|
|
1624
1669
|
] }),
|
|
1625
|
-
/* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */ jsx7(Field, { label: "Default model", children: /* @__PURE__ */ jsx7("input", { className: input, disabled: editingDisabled, value: value.model?.default ?? "", onChange: (event) => model({ ...value.model, default: event.target.value }), placeholder: "provider/model" }) }),
|
|
1627
|
-
/* @__PURE__ */ jsx7(Field, { label: "Small model", children: /* @__PURE__ */ jsx7("input", { className: input, disabled: editingDisabled, value: value.model?.small ?? "", onChange: (event) => model({ ...value.model, small: event.target.value }), placeholder: "provider/model" }) }),
|
|
1628
|
-
/* @__PURE__ */ jsx7(Field, { label: "Provider hint", children: /* @__PURE__ */ jsx7("input", { className: input, disabled: editingDisabled, value: value.model?.provider ?? "", onChange: (event) => model({ ...value.model, provider: event.target.value }) }) }),
|
|
1629
|
-
/* @__PURE__ */ jsx7(Field, { label: "Thinking level", children: /* @__PURE__ */ jsxs5(
|
|
1630
|
-
"select",
|
|
1631
|
-
{
|
|
1632
|
-
className: input,
|
|
1633
|
-
disabled: editingDisabled,
|
|
1634
|
-
value: value.model?.reasoningEffort ?? "",
|
|
1635
|
-
onChange: (event) => model({ ...value.model, reasoningEffort: event.target.value ? event.target.value : void 0 }),
|
|
1636
|
-
children: [
|
|
1637
|
-
/* @__PURE__ */ jsx7("option", { value: "", children: "Harness default" }),
|
|
1638
|
-
["none", "minimal", "low", "medium", "high", "xhigh", "ultracode"].map((level) => /* @__PURE__ */ jsx7("option", { value: level, children: level }, level))
|
|
1639
|
-
]
|
|
1640
|
-
}
|
|
1641
|
-
) })
|
|
1642
|
-
] }) }),
|
|
1643
|
-
/* @__PURE__ */ jsxs5(Section, { title: "Tools and permissions", description: "Choose which tools are available and when each needs approval.", children: [
|
|
1670
|
+
/* @__PURE__ */ jsxs5(Disclosure, { title: "Tools and permissions", description: "Choose which tools are available and when each needs approval.", detail: Object.keys(value.tools ?? {}).length + " configured", children: [
|
|
1644
1671
|
Object.keys(value.tools ?? {}).length === 0 && /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "No tool rules added." }),
|
|
1645
|
-
/* @__PURE__ */ jsx7("div", { className: "space-y-2", children: Object.entries(value.tools ?? {}).map(([name, enabled]) => /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-border p-3 text-sm", children: [
|
|
1672
|
+
/* @__PURE__ */ jsx7("div", { className: "space-y-2", children: Object.entries(value.tools ?? {}).slice(0, showAllTools ? void 0 : 4).map(([name, enabled]) => /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-border p-3 text-sm", children: [
|
|
1646
1673
|
/* @__PURE__ */ jsxs5("label", { className: "flex min-w-32 flex-1 items-center gap-2", children: [
|
|
1647
1674
|
/* @__PURE__ */ jsx7(
|
|
1648
|
-
|
|
1675
|
+
Switch,
|
|
1649
1676
|
{
|
|
1650
|
-
type: "checkbox",
|
|
1651
1677
|
disabled: editingDisabled,
|
|
1652
1678
|
checked: enabled,
|
|
1653
|
-
|
|
1679
|
+
onCheckedChange: (checked) => emit({ ...value, tools: { ...value.tools, [name]: checked } })
|
|
1654
1680
|
}
|
|
1655
1681
|
),
|
|
1656
1682
|
name
|
|
1657
1683
|
] }),
|
|
1658
|
-
/* @__PURE__ */ jsxs5("
|
|
1659
|
-
"Permission",
|
|
1684
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-36 items-center gap-2 text-muted-foreground", children: [
|
|
1685
|
+
/* @__PURE__ */ jsx7("span", { children: "Permission" }),
|
|
1660
1686
|
/* @__PURE__ */ jsxs5(
|
|
1661
|
-
|
|
1687
|
+
Select,
|
|
1662
1688
|
{
|
|
1663
|
-
className: "rounded-md border border-input bg-background px-2 py-1 text-foreground",
|
|
1664
1689
|
disabled: editingDisabled,
|
|
1665
|
-
value: typeof value.permissions?.[name] === "string" ? value.permissions[name] : "",
|
|
1666
|
-
|
|
1690
|
+
value: typeof value.permissions?.[name] === "string" ? value.permissions[name] : "default",
|
|
1691
|
+
onValueChange: (permission) => {
|
|
1667
1692
|
const permissions = { ...value.permissions };
|
|
1668
|
-
if (
|
|
1693
|
+
if (permission !== "default") permissions[name] = permission;
|
|
1669
1694
|
else delete permissions[name];
|
|
1670
1695
|
emit({ ...value, permissions });
|
|
1671
1696
|
},
|
|
1672
1697
|
children: [
|
|
1673
|
-
/* @__PURE__ */ jsx7(
|
|
1674
|
-
/* @__PURE__ */
|
|
1675
|
-
|
|
1676
|
-
|
|
1698
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { "aria-label": "Permission for " + name, children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
1699
|
+
/* @__PURE__ */ jsxs5(SelectContent, { children: [
|
|
1700
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "default", children: "Default" }),
|
|
1701
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "allow", children: "Allow" }),
|
|
1702
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "ask", children: "Ask" }),
|
|
1703
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "deny", children: "Deny" })
|
|
1704
|
+
] })
|
|
1677
1705
|
]
|
|
1678
1706
|
}
|
|
1679
1707
|
)
|
|
1680
1708
|
] }),
|
|
1681
|
-
/* @__PURE__ */ jsx7(
|
|
1709
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "ghost", className: "text-destructive", disabled: editingDisabled, onClick: () => {
|
|
1682
1710
|
const tools = { ...value.tools };
|
|
1683
1711
|
delete tools[name];
|
|
1684
1712
|
emit({ ...value, tools });
|
|
1685
1713
|
}, children: "Remove" })
|
|
1686
1714
|
] }, name)) }),
|
|
1715
|
+
Object.keys(value.tools ?? {}).length > 4 && /* @__PURE__ */ jsx7(Button, { type: "button", variant: "ghost", onClick: () => setShowAllTools((current) => !current), children: showAllTools ? "Show fewer rules" : "Show " + (Object.keys(value.tools ?? {}).length - 4) + " more rules" }),
|
|
1687
1716
|
/* @__PURE__ */ jsxs5("div", { className: "flex gap-2", children: [
|
|
1688
|
-
/* @__PURE__ */ jsx7(
|
|
1689
|
-
/* @__PURE__ */ jsx7(
|
|
1717
|
+
/* @__PURE__ */ jsx7(Input, { "aria-label": "New tool name", disabled: editingDisabled, value: newTool, onChange: (event) => setNewTool(event.target.value), placeholder: "Tool name" }),
|
|
1718
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", disabled: editingDisabled, onClick: () => {
|
|
1690
1719
|
const name = newTool.trim();
|
|
1691
1720
|
if (!name || name in (value.tools ?? {})) {
|
|
1692
1721
|
setError("Enter a unique tool name.");
|
|
@@ -1699,7 +1728,7 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1699
1728
|
] }),
|
|
1700
1729
|
resourceSection("skills", "Skills", "Add skill packages from a repository or inline content."),
|
|
1701
1730
|
resourceSection("tools", "Tool files", "Provide files that a supported harness can discover as tools."),
|
|
1702
|
-
/* @__PURE__ */ jsxs5(
|
|
1731
|
+
/* @__PURE__ */ jsxs5(Disclosure, { title: "MCP servers", description: "Connect remote or local servers. Use secret references for credentials.", detail: Object.keys(value.mcp ?? {}).length + " connected", children: [
|
|
1703
1732
|
Object.keys(value.mcp ?? {}).length === 0 && /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "No servers added." }),
|
|
1704
1733
|
/* @__PURE__ */ jsx7("ul", { className: "space-y-2", children: Object.entries(value.mcp ?? {}).map(([name, server]) => /* @__PURE__ */ jsxs5("li", { className: "flex items-center justify-between gap-3 rounded-lg border border-border p-3 text-sm", children: [
|
|
1705
1734
|
/* @__PURE__ */ jsxs5("div", { className: "min-w-0", children: [
|
|
@@ -1707,25 +1736,28 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1707
1736
|
/* @__PURE__ */ jsx7("span", { className: "ml-2 text-xs text-muted-foreground", children: server.enabled === false ? "Disabled" : "command" in server ? "Local" : "Remote" }),
|
|
1708
1737
|
server.enabled !== false && /* @__PURE__ */ jsx7("p", { className: "truncate text-xs text-muted-foreground", children: "command" in server ? server.command : server.url })
|
|
1709
1738
|
] }),
|
|
1710
|
-
/* @__PURE__ */ jsx7(
|
|
1739
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "ghost", className: "text-destructive", disabled: editingDisabled, onClick: () => {
|
|
1711
1740
|
const mcp = { ...value.mcp };
|
|
1712
1741
|
delete mcp[name];
|
|
1713
1742
|
emit({ ...value, mcp });
|
|
1714
1743
|
}, children: "Remove" })
|
|
1715
1744
|
] }, name)) }),
|
|
1716
1745
|
/* @__PURE__ */ jsxs5("div", { className: "grid gap-3 rounded-lg border border-dashed border-border p-3 sm:grid-cols-[1fr_10rem]", children: [
|
|
1717
|
-
/* @__PURE__ */ jsx7(Field, { label: "Server name", children: /* @__PURE__ */ jsx7(
|
|
1718
|
-
/* @__PURE__ */ jsx7(Field, { label: "Transport", children: /* @__PURE__ */ jsxs5(
|
|
1719
|
-
/* @__PURE__ */ jsx7(
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
|
|
1746
|
+
/* @__PURE__ */ jsx7(Field, { label: "Server name", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: mcpName, onChange: (event) => setMcpName(event.target.value), placeholder: "search" }) }),
|
|
1747
|
+
/* @__PURE__ */ jsx7(Field, { label: "Transport", children: /* @__PURE__ */ jsxs5(Select, { disabled: editingDisabled, value: mcpKind, onValueChange: (kind) => setMcpKind(kind), children: [
|
|
1748
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { "aria-label": "Transport", children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
1749
|
+
/* @__PURE__ */ jsxs5(SelectContent, { children: [
|
|
1750
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "http", children: "HTTP" }),
|
|
1751
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "sse", children: "SSE" }),
|
|
1752
|
+
/* @__PURE__ */ jsx7(SelectItem, { value: "stdio", children: "Local command" })
|
|
1753
|
+
] })
|
|
1722
1754
|
] }) }),
|
|
1723
|
-
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsx7(Field, { label: mcpKind === "stdio" ? "Command" : "URL", children: /* @__PURE__ */ jsx7(
|
|
1724
|
-
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsx7(
|
|
1755
|
+
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsx7(Field, { label: mcpKind === "stdio" ? "Command" : "URL", children: /* @__PURE__ */ jsx7(Input, { disabled: editingDisabled, value: mcpTarget, onChange: (event) => setMcpTarget(event.target.value), placeholder: mcpKind === "stdio" ? "mcp-server" : "https://example.com/mcp" }) }) }),
|
|
1756
|
+
/* @__PURE__ */ jsx7("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", disabled: editingDisabled, onClick: addMcp, children: "Add server" }) })
|
|
1725
1757
|
] }),
|
|
1726
1758
|
/* @__PURE__ */ jsx7("p", { className: "text-xs text-muted-foreground", children: "Arguments, headers, environment, and secret references remain in Advanced JSON." })
|
|
1727
1759
|
] }),
|
|
1728
|
-
/* @__PURE__ */ jsxs5(
|
|
1760
|
+
/* @__PURE__ */ jsxs5(Disclosure, { title: "Resource files", description: "Mount files in the agent workspace. Edit paths and content in Advanced JSON.", detail: (value.resources?.files ?? []).length + " mounted", children: [
|
|
1729
1761
|
(value.resources?.files ?? []).length === 0 && /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "No files mounted." }),
|
|
1730
1762
|
/* @__PURE__ */ jsx7("ul", { className: "space-y-2", children: (value.resources?.files ?? []).map((mount, index) => /* @__PURE__ */ jsxs5("li", { className: "flex items-center justify-between gap-3 rounded-lg border border-border p-3 text-sm", children: [
|
|
1731
1763
|
/* @__PURE__ */ jsxs5("span", { className: "truncate", children: [
|
|
@@ -1736,19 +1768,19 @@ function AgentProfileEditor({ value, onChange, disabled = false, className }) {
|
|
|
1736
1768
|
mount.resource.kind === "github" ? mount.resource.path : mount.resource.name
|
|
1737
1769
|
] })
|
|
1738
1770
|
] }),
|
|
1739
|
-
/* @__PURE__ */ jsx7(
|
|
1771
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "ghost", className: "text-destructive", disabled: editingDisabled, onClick: () => emit({ ...value, resources: { ...value.resources, files: (value.resources?.files ?? []).filter((_, i) => i !== index) } }), children: "Remove" })
|
|
1740
1772
|
] }, index)) }),
|
|
1741
|
-
/* @__PURE__ */ jsx7(
|
|
1773
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", disabled: editingDisabled, onClick: () => emit({ ...value, resources: { ...value.resources, files: [...value.resources?.files ?? [], { path: "new-file.md", resource: { kind: "inline", name: "New file", content: "" } }] } }), children: "Add file" })
|
|
1742
1774
|
] }),
|
|
1743
|
-
/* @__PURE__ */ jsxs5(
|
|
1775
|
+
/* @__PURE__ */ jsxs5(Disclosure, { title: "Advanced JSON", description: "Edit the full canonical profile, including hooks, modes, connections, and extensions.", children: [
|
|
1744
1776
|
/* @__PURE__ */ jsx7("label", { htmlFor: id + "-json", className: "sr-only", children: "Full profile JSON" }),
|
|
1745
|
-
/* @__PURE__ */ jsx7(
|
|
1777
|
+
/* @__PURE__ */ jsx7(Textarea, { id: id + "-json", className: "min-h-72 font-mono text-xs", spellCheck: false, disabled, value: json, onChange: (event) => {
|
|
1746
1778
|
setJson(event.target.value);
|
|
1747
1779
|
setJsonDirty(true);
|
|
1748
1780
|
} }),
|
|
1749
1781
|
/* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1750
|
-
/* @__PURE__ */ jsx7(
|
|
1751
|
-
jsonDirty && /* @__PURE__ */ jsx7(
|
|
1782
|
+
/* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", disabled: disabled || !jsonDirty, onClick: applyJson, children: "Apply JSON" }),
|
|
1783
|
+
jsonDirty && /* @__PURE__ */ jsx7(Button, { type: "button", variant: "ghost", className: "text-destructive", disabled, onClick: () => {
|
|
1752
1784
|
setJson(JSON.stringify(value, null, 2));
|
|
1753
1785
|
setJsonDirty(false);
|
|
1754
1786
|
setError(null);
|
|
@@ -1813,7 +1845,7 @@ async function responseBody(response) {
|
|
|
1813
1845
|
}
|
|
1814
1846
|
function createDurablePlanDecisionClient(options) {
|
|
1815
1847
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
1816
|
-
const urlFor = (
|
|
1848
|
+
const urlFor = (input) => typeof options.url === "function" ? options.url(input) : options.url;
|
|
1817
1849
|
const read = async (response) => {
|
|
1818
1850
|
const body = await responseBody(response);
|
|
1819
1851
|
const result = parseDecisionResult(body);
|
|
@@ -1828,20 +1860,20 @@ function createDurablePlanDecisionClient(options) {
|
|
|
1828
1860
|
);
|
|
1829
1861
|
};
|
|
1830
1862
|
return {
|
|
1831
|
-
async current(
|
|
1832
|
-
const rawUrl = urlFor(
|
|
1863
|
+
async current(input) {
|
|
1864
|
+
const rawUrl = urlFor(input);
|
|
1833
1865
|
const url = new URL(rawUrl, globalThis.location?.origin ?? "http://localhost");
|
|
1834
|
-
url.searchParams.set("planId",
|
|
1835
|
-
if (
|
|
1866
|
+
url.searchParams.set("planId", input.planId);
|
|
1867
|
+
if (input.revision !== void 0) url.searchParams.set("revision", String(input.revision));
|
|
1836
1868
|
const target = /^https?:/.test(rawUrl) ? url.toString() : `${url.pathname}${url.search}`;
|
|
1837
1869
|
return read(await fetchImpl(target, { method: "GET" }));
|
|
1838
1870
|
},
|
|
1839
|
-
async decide(
|
|
1840
|
-
const extra = typeof options.body === "function" ? options.body(
|
|
1841
|
-
return read(await fetchImpl(urlFor(
|
|
1871
|
+
async decide(input) {
|
|
1872
|
+
const extra = typeof options.body === "function" ? options.body(input) : options.body ?? {};
|
|
1873
|
+
return read(await fetchImpl(urlFor(input), {
|
|
1842
1874
|
method: "POST",
|
|
1843
1875
|
headers: { "Content-Type": "application/json" },
|
|
1844
|
-
body: JSON.stringify({ ...extra, ...
|
|
1876
|
+
body: JSON.stringify({ ...extra, ...input })
|
|
1845
1877
|
}));
|
|
1846
1878
|
}
|
|
1847
1879
|
};
|
|
@@ -2680,16 +2712,16 @@ function rollUpProvenanceStanding(record, policy = DEFAULT_PROVENANCE_CONFIDENCE
|
|
|
2680
2712
|
if (seen.has(record)) return "settled";
|
|
2681
2713
|
seen.add(record);
|
|
2682
2714
|
let standing = resolveProvenanceStanding(record, policy);
|
|
2683
|
-
for (const
|
|
2684
|
-
standing = weakerProvenanceStanding(standing, rollUpProvenanceStanding(
|
|
2715
|
+
for (const input of record.inputs ?? []) {
|
|
2716
|
+
standing = weakerProvenanceStanding(standing, rollUpProvenanceStanding(input, policy, seen));
|
|
2685
2717
|
}
|
|
2686
2718
|
return standing;
|
|
2687
2719
|
}
|
|
2688
2720
|
function sourcePhrase(source) {
|
|
2689
2721
|
return source.locator ? `${source.label}, ${source.locator}` : source.label;
|
|
2690
2722
|
}
|
|
2691
|
-
function inputPhrase(
|
|
2692
|
-
return
|
|
2723
|
+
function inputPhrase(input) {
|
|
2724
|
+
return input.label ?? input.display;
|
|
2693
2725
|
}
|
|
2694
2726
|
function describeProvenance(record) {
|
|
2695
2727
|
const sources = record.sources ?? [];
|
|
@@ -3015,17 +3047,17 @@ function ProvenanceValue({
|
|
|
3015
3047
|
loading.length > 0 && sources.length === 0 && /* @__PURE__ */ jsx9("p", { role: "status", className: "text-xs text-muted-foreground", children: "Looking up where this came from\u2026" }),
|
|
3016
3048
|
inputs.length > 0 && /* @__PURE__ */ jsxs7("div", { className: "border-t border-border pt-2", children: [
|
|
3017
3049
|
/* @__PURE__ */ jsx9("p", { className: "text-xs font-medium uppercase tracking-[0.05em] text-muted-foreground", children: record.derivation ? `Computed from ${record.derivation}` : "Computed from" }),
|
|
3018
|
-
/* @__PURE__ */ jsx9("ul", { className: "mt-1.5 space-y-1.5", children: inputs.map((
|
|
3050
|
+
/* @__PURE__ */ jsx9("ul", { className: "mt-1.5 space-y-1.5", children: inputs.map((input, index) => /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsx9(
|
|
3019
3051
|
ProvenanceValue,
|
|
3020
3052
|
{
|
|
3021
|
-
record:
|
|
3053
|
+
record: input,
|
|
3022
3054
|
onOpenSource,
|
|
3023
3055
|
onRetrySource,
|
|
3024
3056
|
confidencePolicy,
|
|
3025
3057
|
maxDepth: maxDepth - 1,
|
|
3026
3058
|
missingValueLabel
|
|
3027
3059
|
}
|
|
3028
|
-
) }, `${
|
|
3060
|
+
) }, `${input.label ?? input.display}-${index}`)) })
|
|
3029
3061
|
] })
|
|
3030
3062
|
]
|
|
3031
3063
|
}
|
|
@@ -6512,4 +6544,4 @@ export {
|
|
|
6512
6544
|
useThinkingSeconds,
|
|
6513
6545
|
ChatMessages
|
|
6514
6546
|
};
|
|
6515
|
-
//# sourceMappingURL=chunk-
|
|
6547
|
+
//# sourceMappingURL=chunk-O2UKPZRF.js.map
|