Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions apps/mobile/src/features/threads/LinkRequestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
linkRequestFailureMessage,
linkRequestInitialMachine,
type LinkRequestItem,
linkRequestKeepsLink,
linkRequestTarget,
rankMachinesByHint,
} from "@t3tools/client-runtime/link-request";
Expand Down Expand Up @@ -243,15 +244,15 @@ function LinkRequestSheet(props: {
Option.isSome(connected) &&
mayMint &&
!mintFailed.has(targetId);
const useExisting = target.kind === "machine" && target.linked;
const useExisting = linkRequestKeepsLink(item, target);
const ready =
target.kind !== "none" &&
(useExisting ||
((!needsAddress || address.trim().length > 0) && (canMint || pairingCode.trim().length > 0)));

const prepareAnswer = async () => {
if (target.kind === "none") return null;
if (target.kind === "machine" && target.linked) {
if (useExisting && target.kind === "machine") {
return linkRequestAnswerInput(item, {
type: "use-existing",
environmentId: target.environmentId,
Expand Down Expand Up @@ -407,6 +408,11 @@ function LinkRequestSheet(props: {
</Text>
) : target.kind === "none" ? null : (
<>
{target.kind === "machine" && target.linkedAccess !== null ? (
<Text className="font-sans text-sm leading-5 text-foreground-muted">
<T>Already linked. Linking again renews it with the access you pick.</T>
</Text>
) : null}
{canMint ? null : (
<View className="gap-2">
<TextInput
Expand Down Expand Up @@ -501,13 +507,14 @@ function MachineRow(props: {
}) {
const gt = useGT();
const { machine } = props;
const status = machine.linked
? gt("Linked")
: machine.connected
? null
: machine.connectOnly
? "T3 Connect"
: gt("Not connected");
const status =
machine.linkedAccess !== null
? gt("Linked")
: machine.connected
? null
: machine.connectOnly
? "T3 Connect"
: gt("Not connected");
return (
<Pressable
accessibilityRole="radio"
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Möglicherweise wurde er dort gelöscht.",
"f7870ef3a4828ab1": "{label} braucht ein Update",
"eabbf064657519ee": "{label} antwortet {via} nicht",
"8855350e81d45c45": "Diese Verknüpfung wurde entfernt oder ist abgelaufen. Verknüpfe den Computer erneut.",
"b3861bc247c3c4bf": "Die Verknüpfungsanfrage konnte nicht geladen werden.",
"81aa3f047d92ed7a": "Diese Verknüpfungsanfrage existiert nicht mehr.",
"6f053c4e5b6f372f": "Diese Verknüpfungsanfrage wurde bereits beantwortet.",
"6d50d5b72fd543f7": "Die Verknüpfungsanfrage konnte nicht aktualisiert werden.",
"f71597ae3afaef44": "{first} und {second}",
"4047174839a16714": "{first} und {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4140,6 +4145,7 @@
},
" verknüpft. Der Agent kann diese Verknüpfung so verwenden; ändere den Zugriff unter Einstellungen → Umgebungen."
],
"dc9a0b68d101e904": "Bereits verknüpft. Erneutes Verknüpfen verlängert sie mit dem gewählten Zugriff.",
"e8235ebb43ad7228": "Erstelle auf einem Rechner einen Link: Einstellungen → Freigabe & Zugriff → Autorisierte Clients → Link erstellen, und füge dann seinen Code hier ein.",
"a974e6c3c613e452": [
"Erstelle einen Link auf ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "It may have been deleted there.",
"f7870ef3a4828ab1": "{label} needs an update",
"eabbf064657519ee": "{label} is not answering {via}",
"b3861bc247c3c4bf": "Could not load the link request.",
"81aa3f047d92ed7a": "This link request no longer exists.",
"6f053c4e5b6f372f": "This link request was already answered.",
"8855350e81d45c45": "That link was removed or expired. Link the machine again.",
"6d50d5b72fd543f7": "Could not update the link request.",
"f71597ae3afaef44": "{first} and {second}",
"4047174839a16714": "{first}, and {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4141,6 +4146,7 @@
},
". The agent can use that link as it is; change its access in Settings → Environments."
],
"dc9a0b68d101e904": "Already linked. Linking again renews it with the access you pick.",
"e8235ebb43ad7228": "Create a link on a machine: Settings → Sharing & access → Authorized clients → Create link, then paste its code here.",
"a974e6c3c613e452": [
"Create a link on ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Puede que se haya eliminado allí.",
"f7870ef3a4828ab1": "{label} necesita una actualización",
"eabbf064657519ee": "{label} no responde a {via}",
"8855350e81d45c45": "Ese vínculo se eliminó o caducó. Vuelve a vincular la máquina.",
"b3861bc247c3c4bf": "No se pudo cargar la solicitud de vínculo.",
"81aa3f047d92ed7a": "Esta solicitud de vínculo ya no existe.",
"6f053c4e5b6f372f": "Esta solicitud de vínculo ya fue respondida.",
"6d50d5b72fd543f7": "No se pudo actualizar la solicitud de vínculo.",
"f71597ae3afaef44": "{first} y {second}",
"4047174839a16714": "{first} y {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4135,6 +4140,7 @@
},
". El agente puede usar ese vínculo tal cual; cambia su acceso en Ajustes → Entornos."
],
"dc9a0b68d101e904": "Ya está vinculado. Vincularlo de nuevo lo renueva con el acceso que elijas.",
"e8235ebb43ad7228": "Crea un enlace en una máquina: Ajustes → Compartir y acceso → Clientes autorizados → Crear enlace, y pega aquí su código.",
"a974e6c3c613e452": [
"Crea un enlace en ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Il a peut-être été supprimé là-bas.",
"f7870ef3a4828ab1": "{label} a besoin d’une mise à jour",
"eabbf064657519ee": "{label} ne répond pas à {via}",
"8855350e81d45c45": "Cette association a été supprimée ou a expiré. Associez à nouveau la machine.",
"b3861bc247c3c4bf": "Impossible de charger la demande d’association.",
"81aa3f047d92ed7a": "Cette demande d’association n’existe plus.",
"6f053c4e5b6f372f": "Cette demande d’association a déjà reçu une réponse.",
"6d50d5b72fd543f7": "Impossible de mettre à jour la demande d’association.",
"f71597ae3afaef44": "{first} et {second}",
"4047174839a16714": "{first} et {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4135,6 +4140,7 @@
},
". L’agent peut utiliser cette association telle quelle ; modifiez son accès dans Paramètres → Environnements."
],
"dc9a0b68d101e904": "Déjà associé. Associer à nouveau renouvelle l’association avec l’accès que vous choisissez.",
"e8235ebb43ad7228": "Créez un lien sur une machine : Paramètres → Partage et accès → Clients autorisés → Créer un lien, puis collez son code ici.",
"a974e6c3c613e452": [
"Créez un lien sur ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "そちらで削除された可能性があります。",
"f7870ef3a4828ab1": "{label} の更新が必要です",
"eabbf064657519ee": "{label} が {via} に応答していません",
"8855350e81d45c45": "そのリンクは削除されたか、期限切れです。マシンをもう一度リンクしてください。",
"b3861bc247c3c4bf": "リンクリクエストを読み込めませんでした。",
"81aa3f047d92ed7a": "このリンクリクエストはもう存在しません。",
"6f053c4e5b6f372f": "このリンクリクエストはすでに回答済みです。",
"6d50d5b72fd543f7": "リンクリクエストを更新できませんでした。",
"f71597ae3afaef44": "{first} と {second}",
"4047174839a16714": "{first}、{last}",
"65ca7867c176afbf": "{first}、{rest}",
Expand Down Expand Up @@ -4132,6 +4137,7 @@
},
" にリンクされています。エージェントはそのリンクをそのまま使用できます。アクセス権は [設定] → [環境] で変更してください。"
],
"dc9a0b68d101e904": "すでにリンクされています。再度リンクすると、選択したアクセス権で更新されます。",
"e8235ebb43ad7228": "マシンでリンクを作成してください (設定 → 共有とアクセス → 認可済みクライアント → リンクを作成)。その後、コードをここに貼り付けてください。",
"a974e6c3c613e452": [
{
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "그곳에서 삭제되었을 수 있습니다.",
"f7870ef3a4828ab1": "{label}을(를) 업데이트해야 합니다",
"eabbf064657519ee": "{label}이(가) {via}에 응답하지 않습니다",
"8855350e81d45c45": "해당 연결이 삭제되었거나 만료되었습니다. 머신을 다시 연결하세요.",
"b3861bc247c3c4bf": "연결 요청을 불러올 수 없습니다.",
"81aa3f047d92ed7a": "이 연결 요청은 더 이상 존재하지 않습니다.",
"6f053c4e5b6f372f": "이 연결 요청은 이미 응답되었습니다.",
"6d50d5b72fd543f7": "연결 요청을 업데이트할 수 없습니다.",
"f71597ae3afaef44": "{first} 및 {second}",
"4047174839a16714": "{first} 및 {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4136,6 +4141,7 @@
},
"에 연결되어 있습니다. 에이전트는 이 연결을 그대로 사용할 수 있으며, 액세스는 설정 → 환경에서 변경하세요."
],
"dc9a0b68d101e904": "이미 연결되어 있습니다. 다시 연결하면 선택한 액세스 권한으로 갱신됩니다.",
"e8235ebb43ad7228": "머신에서 링크를 만드세요: 설정 → 공유 및 액세스 → 승인된 클라이언트 → 링크 만들기. 그런 다음 코드를 여기에 붙여 넣으세요.",
"a974e6c3c613e452": [
{
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Talvez tenha sido excluída lá.",
"f7870ef3a4828ab1": "{label} precisa de uma atualização",
"eabbf064657519ee": "{label} não está respondendo a {via}",
"8855350e81d45c45": "Esse vínculo foi removido ou expirou. Vincule a máquina novamente.",
"b3861bc247c3c4bf": "Não foi possível carregar a solicitação de vínculo.",
"81aa3f047d92ed7a": "Esta solicitação de vínculo não existe mais.",
"6f053c4e5b6f372f": "Esta solicitação de vínculo já foi respondida.",
"6d50d5b72fd543f7": "Não foi possível atualizar a solicitação de vínculo.",
"f71597ae3afaef44": "{first} e {second}",
"4047174839a16714": "{first} e {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4135,6 +4140,7 @@
},
". O agente pode usar esse vínculo como está; altere o acesso em Configurações → Ambientes."
],
"dc9a0b68d101e904": "Já vinculado. Vincular novamente renova o vínculo com o acesso escolhido.",
"e8235ebb43ad7228": "Crie um link em uma máquina: Configurações → Compartilhamento e acesso → Clientes autorizados → Criar link e cole o código aqui.",
"a974e6c3c613e452": [
"Crie um link em ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Возможно, его там удалили.",
"f7870ef3a4828ab1": "{label} нужно обновить",
"eabbf064657519ee": "{label} не отвечает {via}",
"8855350e81d45c45": "Эта привязка удалена или истекла. Привяжите машину снова.",
"b3861bc247c3c4bf": "Не удалось загрузить запрос на привязку.",
"81aa3f047d92ed7a": "Этот запрос на привязку больше не существует.",
"6f053c4e5b6f372f": "На этот запрос на привязку уже дан ответ.",
"6d50d5b72fd543f7": "Не удалось обновить запрос на привязку.",
"f71597ae3afaef44": "{first} и {second}",
"4047174839a16714": "{first} и {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4189,6 +4194,7 @@
},
". Агент может использовать эту привязку как есть; изменить её доступ можно в «Настройки → Окружения»."
],
"dc9a0b68d101e904": "Уже привязано. Повторная привязка продлевает её с выбранным уровнем доступа.",
"e8235ebb43ad7228": "Создайте ссылку на компьютере: Настройки → Общий доступ → Авторизованные клиенты → Создать ссылку, затем вставьте её код сюда.",
"a974e6c3c613e452": [
"Создайте ссылку на ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "Den kan ha raderats där.",
"f7870ef3a4828ab1": "{label} behöver uppdateras",
"eabbf064657519ee": "{label} svarar inte {via}",
"8855350e81d45c45": "Länken har tagits bort eller gått ut. Länka maskinen igen.",
"b3861bc247c3c4bf": "Det gick inte att läsa in länkförfrågan.",
"81aa3f047d92ed7a": "Den här länkförfrågan finns inte längre.",
"6f053c4e5b6f372f": "Den här länkförfrågan har redan besvarats.",
"6d50d5b72fd543f7": "Det gick inte att uppdatera länkförfrågan.",
"f71597ae3afaef44": "{first} och {second}",
"4047174839a16714": "{first} och {last}",
"65ca7867c176afbf": "{first}, {rest}",
Expand Down Expand Up @@ -4141,6 +4146,7 @@
},
". Agenten kan använda den länken som den är; ändra dess åtkomst under Inställningar → Miljöer."
],
"dc9a0b68d101e904": "Redan länkad. Om du länkar igen förnyas den med den åtkomst du väljer.",
"e8235ebb43ad7228": "Skapa en länk på en dator: Inställningar → Delning och åtkomst → Auktoriserade klienter → Skapa länk, och klistra sedan in koden här.",
"a974e6c3c613e452": [
"Skapa en länk på ",
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"bd29efc163476e72": "它可能已在那里被删除。",
"f7870ef3a4828ab1": "{label} 需要更新",
"eabbf064657519ee": "{label} 没有响应 {via}",
"8855350e81d45c45": "该关联已被移除或已过期。请重新关联这台机器。",
"b3861bc247c3c4bf": "无法加载关联请求。",
"81aa3f047d92ed7a": "此关联请求已不存在。",
"6f053c4e5b6f372f": "此关联请求已被回答。",
"6d50d5b72fd543f7": "无法更新关联请求。",
"f71597ae3afaef44": "{first} 和 {second}",
"4047174839a16714": "{first} 和 {last}",
"65ca7867c176afbf": "{first}、{rest}",
Expand Down Expand Up @@ -4138,6 +4143,7 @@
},
"。智能体可以直接使用该关联;请在“设置 → 环境”中更改其访问权限。"
],
"dc9a0b68d101e904": "已关联。再次关联将使用你选择的访问权限续期。",
"e8235ebb43ad7228": "在某台机器上创建链接:设置 → 共享与访问 → 已授权的客户端 → 创建链接,然后在此处粘贴配对码。",
"a974e6c3c613e452": [
"在 ",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/orchestrator/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const EnvironmentLinksTool = Tool.make("t3_environment_links", {

const EnvironmentLinkTool = Tool.make("t3_environment_link", {
description:
"Ask the user to link another machine, in a card. For a machine the user names that is not linked. Pass `hint` from their words, `environmentId` when one names it (already linked: returns `linked`), `url` only when the user gave an address. Returns `pending`; the outcome arrives as a message in this thread. Do not wait, poll, or call it again to check. Never ask for a pairing code in chat.",
"Ask the user, in a card, to link a machine they name that is unlinked or linked below the access needed. Pass `hint` from their words, `environmentId` when one names it (returns `linked` if it has `requestedAccess`), `url` only if the user gave one. Returns `pending`; the outcome arrives as a message here. Do not wait, poll, or call it again. Never ask for a pairing code in chat.",
parameters: OrchestratorMcpEnvironmentLinkInput,
success: OrchestratorMcpEnvironmentLinkResult,
failure: OrchestratorMcpFailure,
Expand Down
77 changes: 64 additions & 13 deletions apps/server/src/peer/PeerLinkRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,19 +1037,25 @@ it.live(
),
);

it.live("naming a machine that is already linked returns the link at once, with no card", () =>
it.live("naming a machine linked with enough access returns the link at once, with no card", () =>
withBoth((a, b) =>
Effect.gen(function* () {
yield* seedThread(a);
const pairing = yield* b.auth.issuePairingCredential();
yield* a.links.link({ url: b.url, pairingCode: pairing.credential, access: "auto" });
const asked = yield* a.call({ environmentId: box.environmentId });
expect(asked.structuredContent).toEqual({
status: "linked",
environmentId: box.environmentId,
label: "Box",
access: "auto",
});
for (const asks of [
{},
{ requestedAccess: "approval-required" },
{ requestedAccess: "auto" },
]) {
const asked = yield* a.call({ environmentId: box.environmentId, ...asks });
expect(asked.structuredContent).toEqual({
status: "linked",
environmentId: box.environmentId,
label: "Box",
access: "auto",
});
}
expect(yield* cardOf(a)).toBeUndefined();

// Not both: the address could name another machine than the id.
Expand Down Expand Up @@ -1088,6 +1094,49 @@ it.live("a retry naming a machine linked meanwhile closes the card it left as li
),
);

it.live("a machine linked with less access than asked goes through the card, which raises it", () =>
withBoth((a, b) =>
Effect.gen(function* () {
yield* seedThread(a);
yield* linkTo(a.links, b, "read-only");
const card = yield* ask(a, {
environmentId: box.environmentId,
requestedAccess: "full-access",
});
expect(card).toMatchObject({ linkStatus: "pending", requestedAccess: "full-access" });
// Naming no access, or no more than the link has, takes the link as it is.
for (const asks of [{}, { requestedAccess: "read-only" }]) {
expect(
(yield* a.call({ environmentId: box.environmentId, ...asks })).structuredContent,
).toMatchObject({ status: "linked", access: "read-only" });
}
expect((yield* linkCards(a)).filter((item) => item.linkStatus === "pending")).toEqual([card]);

// Linking again over the old link replaces it; nothing is unlinked first.
const pairing = yield* b.auth.issuePairingCredential();
yield* a.requests.answer({
threadId,
turnItemId: card.id,
answer: {
type: "link",
environmentId: box.environmentId,
label: "Box",
urls: [b.url],
access: "full-access",
pairingCode: pairing.credential,
},
});
expect((yield* linkCards(a)).find((item) => item.id === card.id)).toMatchObject({
linkStatus: "linked",
linkedAccess: "full-access",
});
expect(Option.getOrUndefined(yield* a.links.get(box.environmentId))).toMatchObject({
access: "full-access",
});
}),
),
);

it.live("a link that expired goes through the card, so the user can link it again", () =>
withBoth((a, b) =>
Effect.gen(function* () {
Expand All @@ -1097,16 +1146,18 @@ it.live("a link that expired goes through the card, so the user can link it agai
expect(asked.structuredContent).toMatchObject({ status: "pending" });
const card = yield* pendingCard(a);

// Keeping the expired link is no answer: the card fails and says why.
yield* a.requests
// Keeping the expired link is no answer, as when a client's list still shows one
// removed meanwhile; the card stays open for the user to link again.
const kept = yield* a.requests
.answer({
threadId,
turnItemId: card.id,
answer: { type: "use-existing", environmentId: box.environmentId },
})
.pipe(afterLinksExpire);
expect(yield* cardOf(a)).toMatchObject({ linkStatus: "failed" });
expect((yield* outcomeMessages(a)).messages[0]!.text).toContain("expired");
.pipe(afterLinksExpire, Effect.flip);
expect(kept.reason).toBe("link_gone");
expect(yield* cardOf(a)).toMatchObject({ linkStatus: "pending" });
expect((yield* outcomeMessages(a)).messages).toHaveLength(0);
}),
),
);
Expand Down
Loading
Loading