@tangle-network/agent-app 0.58.15 → 0.58.17
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/VaultPane-RIJM452Y.js +7 -0
- package/dist/assistant/index.js +13 -11
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +4 -4
- package/dist/chat-routes/index.js +4 -4
- package/dist/chat-store/index.js +2 -2
- package/dist/{chunk-POE5UUUT.js → chunk-55JJKE7S.js} +3 -3
- package/dist/chunk-B7CL7ENS.js +118 -0
- package/dist/chunk-B7CL7ENS.js.map +1 -0
- package/dist/{chunk-EXBAVMMK.js → chunk-DECJLOS4.js} +347 -311
- package/dist/chunk-DECJLOS4.js.map +1 -0
- package/dist/{chunk-NWR5CERQ.js → chunk-FNRUXPXE.js} +2 -2
- package/dist/{chunk-T5U7LDQW.js → chunk-HG4OONJA.js} +53 -15
- package/dist/chunk-HG4OONJA.js.map +1 -0
- package/dist/{chunk-WTGSLW5X.js → chunk-HTAFI247.js} +4 -4
- package/dist/{chunk-MLG7YSTS.js → chunk-KHCJKVQN.js} +3 -3
- package/dist/{chunk-GIBNG64C.js → chunk-LYDOZKSX.js} +2607 -1438
- package/dist/chunk-LYDOZKSX.js.map +1 -0
- package/dist/{chunk-57TTYY6T.js → chunk-NJDQ2JCP.js} +2 -2
- package/dist/chunk-PV33JZKV.js +115 -0
- package/dist/chunk-PV33JZKV.js.map +1 -0
- package/dist/{chunk-EN5CP7T7.js → chunk-T5PPQPOD.js} +5 -111
- package/dist/chunk-T5PPQPOD.js.map +1 -0
- package/dist/{chunk-DWUBICLW.js → chunk-UGPV7VEW.js} +569 -236
- package/dist/chunk-UGPV7VEW.js.map +1 -0
- package/dist/{chunk-TUNRLEDH.js → chunk-XEURJVS5.js} +2 -2
- package/dist/{mention-editor-W2GG2NZ7.js → mention-editor-5KXHSBDJ.js} +2 -2
- package/dist/preset-cloudflare/index.js +3 -3
- package/dist/profile/index.js +4 -2
- package/dist/profile/index.js.map +1 -1
- package/dist/profile-editor/index.d.ts +185 -0
- package/dist/profile-editor/index.js +18 -0
- package/dist/profile-editor/index.js.map +1 -0
- package/dist/profile-editor/server.d.ts +112 -0
- package/dist/profile-editor/server.js +635 -0
- package/dist/profile-editor/server.js.map +1 -0
- package/dist/public-consultation/index.js +4 -4
- package/dist/skills/frontmatter.d.ts +43 -0
- package/dist/skills/index.d.ts +1 -38
- package/dist/skills/index.js +4 -2
- package/dist/skills-placement/index.js +2 -1
- package/dist/skills-placement/index.js.map +1 -1
- package/dist/stories/fixtures/profile-editor.d.ts +17 -0
- package/dist/studio-react/index.js +3 -3
- package/dist/teams/invitations-api.js +3 -3
- package/dist/vault/VaultPane.d.ts +4 -4
- package/dist/vault/VaultTree.d.ts +39 -0
- package/dist/vault/contracts.d.ts +17 -7
- package/dist/vault/index.d.ts +5 -4
- package/dist/vault/index.js +7 -3
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/agent-profile-editor.d.ts +63 -1
- package/dist/web-react/agent-profile-files.d.ts +38 -0
- package/dist/web-react/agent-profile-form-kit.d.ts +87 -0
- package/dist/web-react/agent-profile-github-source.d.ts +35 -0
- package/dist/web-react/agent-profile-mcp-servers.d.ts +20 -0
- package/dist/web-react/agent-profile-suggest-input.d.ts +31 -0
- package/dist/web-react/agent-session-controls.d.ts +51 -0
- package/dist/web-react/controls.d.ts +29 -3
- package/dist/web-react/index.d.ts +3 -2
- package/dist/web-react/index.js +23 -15
- package/dist/workspace-react/index.js +4 -4
- package/package.json +11 -1
- package/dist/VaultPane-SPXE7XAC.js +0 -7
- package/dist/chunk-DWUBICLW.js.map +0 -1
- package/dist/chunk-EN5CP7T7.js.map +0 -1
- package/dist/chunk-EXBAVMMK.js.map +0 -1
- package/dist/chunk-GIBNG64C.js.map +0 -1
- package/dist/chunk-T5U7LDQW.js.map +0 -1
- /package/dist/{VaultPane-SPXE7XAC.js.map → VaultPane-RIJM452Y.js.map} +0 -0
- /package/dist/{chunk-POE5UUUT.js.map → chunk-55JJKE7S.js.map} +0 -0
- /package/dist/{chunk-NWR5CERQ.js.map → chunk-FNRUXPXE.js.map} +0 -0
- /package/dist/{chunk-WTGSLW5X.js.map → chunk-HTAFI247.js.map} +0 -0
- /package/dist/{chunk-MLG7YSTS.js.map → chunk-KHCJKVQN.js.map} +0 -0
- /package/dist/{chunk-57TTYY6T.js.map → chunk-NJDQ2JCP.js.map} +0 -0
- /package/dist/{chunk-TUNRLEDH.js.map → chunk-XEURJVS5.js.map} +0 -0
- /package/dist/{mention-editor-W2GG2NZ7.js.map → mention-editor-5KXHSBDJ.js.map} +0 -0
package/dist/chat-react/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComposerModeControls,
|
|
3
3
|
EntryComposer
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-DECJLOS4.js";
|
|
5
5
|
import "../chunk-L7MB2LLM.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-NJDQ2JCP.js";
|
|
7
|
+
import "../chunk-HG4OONJA.js";
|
|
8
8
|
import "../chunk-SJWIZT7B.js";
|
|
9
|
-
import "../chunk-MLG6XKPV.js";
|
|
10
9
|
import "../chunk-NJA6X7JI.js";
|
|
10
|
+
import "../chunk-MLG6XKPV.js";
|
|
11
11
|
import "../chunk-MCYJON3F.js";
|
|
12
12
|
import "../chunk-7YA4QNTU.js";
|
|
13
13
|
import "../chunk-GYDFGEJ2.js";
|
|
@@ -64,9 +64,9 @@ import {
|
|
|
64
64
|
rowIdOf,
|
|
65
65
|
storeSupportsDraftPersistence,
|
|
66
66
|
streamChatRouteAsSandboxEvents
|
|
67
|
-
} from "../chunk-
|
|
68
|
-
import "../chunk-YNSPVKMS.js";
|
|
67
|
+
} from "../chunk-FNRUXPXE.js";
|
|
69
68
|
import "../chunk-6VRVRWYN.js";
|
|
69
|
+
import "../chunk-YNSPVKMS.js";
|
|
70
70
|
import "../chunk-3NCPXNBZ.js";
|
|
71
71
|
import "../chunk-53K4S3K6.js";
|
|
72
72
|
import {
|
|
@@ -77,7 +77,8 @@ import {
|
|
|
77
77
|
attachmentInputToPart,
|
|
78
78
|
attachmentKindForMime,
|
|
79
79
|
toChatMessageParts
|
|
80
|
-
} from "../chunk-
|
|
80
|
+
} from "../chunk-HTAFI247.js";
|
|
81
|
+
import "../chunk-ZVEEWGDK.js";
|
|
81
82
|
import {
|
|
82
83
|
ChatTurnInputError,
|
|
83
84
|
DISPATCH_MAX_MEDIA_PARTS,
|
|
@@ -99,7 +100,6 @@ import {
|
|
|
99
100
|
promptPartsByteSize,
|
|
100
101
|
validateSandboxMentionPath
|
|
101
102
|
} from "../chunk-GYDFGEJ2.js";
|
|
102
|
-
import "../chunk-ZVEEWGDK.js";
|
|
103
103
|
import {
|
|
104
104
|
isWorkspaceFileExportable
|
|
105
105
|
} from "../chunk-TXD5HXLE.js";
|
package/dist/chat-store/index.js
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
mentionInputToPart,
|
|
15
15
|
mentionPartsFromMessageParts,
|
|
16
16
|
toChatMessageParts
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-GYDFGEJ2.js";
|
|
17
|
+
} from "../chunk-HTAFI247.js";
|
|
19
18
|
import "../chunk-ZVEEWGDK.js";
|
|
19
|
+
import "../chunk-GYDFGEJ2.js";
|
|
20
20
|
import "../chunk-TXD5HXLE.js";
|
|
21
21
|
import {
|
|
22
22
|
attachmentPartKey
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActionDialog,
|
|
3
3
|
ActionDialogButton
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XEURJVS5.js";
|
|
5
5
|
import {
|
|
6
6
|
OVERLAY_SHADOW,
|
|
7
7
|
PopoverSurface,
|
|
8
8
|
usePopover
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HG4OONJA.js";
|
|
10
10
|
import {
|
|
11
11
|
UNTITLED_SESSION_LABEL,
|
|
12
12
|
mergeSessionPages,
|
|
@@ -751,4 +751,4 @@ export {
|
|
|
751
751
|
formatSessionTimestamp,
|
|
752
752
|
SessionHistoryPanel
|
|
753
753
|
};
|
|
754
|
-
//# sourceMappingURL=chunk-
|
|
754
|
+
//# sourceMappingURL=chunk-55JJKE7S.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseSkillFrontmatter
|
|
3
|
+
} from "./chunk-PV33JZKV.js";
|
|
4
|
+
|
|
5
|
+
// src/profile-editor/index.ts
|
|
6
|
+
var PROFILE_EDITOR_ROUTES = {
|
|
7
|
+
repositories: "github/repositories",
|
|
8
|
+
latest: "github/latest",
|
|
9
|
+
commit: "github/commit",
|
|
10
|
+
files: "github/files",
|
|
11
|
+
check: "github/check",
|
|
12
|
+
mcpCheck: "mcp/check"
|
|
13
|
+
};
|
|
14
|
+
function unavailable(message) {
|
|
15
|
+
return { ok: false, problem: "unavailable", message };
|
|
16
|
+
}
|
|
17
|
+
function createProfileEditorClient({ endpoint, fetch: fetchImpl }) {
|
|
18
|
+
const base = endpoint.replace(/\/+$/, "");
|
|
19
|
+
const send = fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
|
|
20
|
+
async function call(path, init, failure) {
|
|
21
|
+
const query = init.query ? "?" + new URLSearchParams(init.query).toString() : "";
|
|
22
|
+
try {
|
|
23
|
+
const response = await send(`${base}/${path}${query}`, {
|
|
24
|
+
method: init.method ?? "GET",
|
|
25
|
+
signal: init.signal,
|
|
26
|
+
credentials: "same-origin",
|
|
27
|
+
headers: init.body ? { "Content-Type": "application/json" } : void 0,
|
|
28
|
+
body: init.body
|
|
29
|
+
});
|
|
30
|
+
const body = await response.json().catch(() => null);
|
|
31
|
+
if (response.ok && body && typeof body === "object" && "ok" in body) return body;
|
|
32
|
+
const detail = body && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : "";
|
|
33
|
+
if (response.status === 401 || response.status === 403) return failure(detail || "You do not have access to check sources for this workspace.");
|
|
34
|
+
return failure(detail || `The source check could not complete (HTTP ${response.status}).`);
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
if (init.signal?.aborted) throw cause;
|
|
37
|
+
return failure("The source check could not reach the server. Check your connection and try again.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const github = {
|
|
41
|
+
repositories: (signal) => call(PROFILE_EDITOR_ROUTES.repositories, { signal }, unavailable),
|
|
42
|
+
latest: (repository, signal) => call(PROFILE_EDITOR_ROUTES.latest, { signal, query: { repository } }, unavailable),
|
|
43
|
+
commit: (repository, sha, signal) => call(PROFILE_EDITOR_ROUTES.commit, { signal, query: { repository, sha } }, unavailable),
|
|
44
|
+
files: (repository, commit, signal) => call(PROFILE_EDITOR_ROUTES.files, { signal, query: { repository, commit } }, unavailable),
|
|
45
|
+
check: (request, signal) => call(PROFILE_EDITOR_ROUTES.check, { signal, method: "POST", body: JSON.stringify(request) }, unavailable)
|
|
46
|
+
};
|
|
47
|
+
const mcp = {
|
|
48
|
+
check: (server, signal) => call(
|
|
49
|
+
PROFILE_EDITOR_ROUTES.mcpCheck,
|
|
50
|
+
{ signal, method: "POST", body: JSON.stringify({ server }) },
|
|
51
|
+
(message) => ({ ok: false, problem: "unavailable", message, checkedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
52
|
+
)
|
|
53
|
+
};
|
|
54
|
+
return { github, mcp };
|
|
55
|
+
}
|
|
56
|
+
var REPOSITORY_SEGMENT = /^[A-Za-z0-9_.-]{1,100}$/;
|
|
57
|
+
function parseGitHubLocation(input) {
|
|
58
|
+
let text = input.trim();
|
|
59
|
+
if (!text) return null;
|
|
60
|
+
const ssh = /^git@github\.com:(.+?)(?:\.git)?$/i.exec(text);
|
|
61
|
+
if (ssh) text = ssh[1];
|
|
62
|
+
else if (/^(https?:\/\/)?(www\.)?github\.com\//i.test(text)) {
|
|
63
|
+
try {
|
|
64
|
+
const url = new URL(/^https?:/i.test(text) ? text : "https://" + text);
|
|
65
|
+
text = url.pathname.replace(/^\/+/, "").replace(/\.git$/, "");
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const [owner, repo, kind, ref, ...rest] = text.split("/").filter(Boolean);
|
|
71
|
+
if (!owner || !repo || !REPOSITORY_SEGMENT.test(owner) || !REPOSITORY_SEGMENT.test(repo) || owner === "." || owner === ".." || repo === "." || repo === "..") return null;
|
|
72
|
+
const repository = `${owner}/${repo.replace(/\.git$/, "")}`;
|
|
73
|
+
if ((kind === "tree" || kind === "blob") && ref) return { repository, ref, ...rest.length ? { path: rest.join("/") } : {} };
|
|
74
|
+
return kind ? null : { repository };
|
|
75
|
+
}
|
|
76
|
+
function isCommitSha(value) {
|
|
77
|
+
return /^[0-9a-f]{40}$/i.test(value);
|
|
78
|
+
}
|
|
79
|
+
function publicHttpsUrlProblem(value) {
|
|
80
|
+
let url;
|
|
81
|
+
try {
|
|
82
|
+
url = new URL(value);
|
|
83
|
+
} catch {
|
|
84
|
+
return "Enter a full URL, such as https://example.com/mcp.";
|
|
85
|
+
}
|
|
86
|
+
if (url.protocol !== "https:") return "Use a public HTTPS address that starts with https://.";
|
|
87
|
+
if (url.username || url.password) return "Remove the credentials from the URL. Use a secret reference in a header instead.";
|
|
88
|
+
if (url.search || url.hash) return "Remove the query and fragment from the URL. Send credentials as a secret reference in a header.";
|
|
89
|
+
const host = url.hostname.toLowerCase();
|
|
90
|
+
if (!host.includes(".") || /^\d+\.\d+\.\d+\.\d+$/.test(host) || host.startsWith("[") || host.endsWith(".local") || host.endsWith(".internal") || host.endsWith(".localhost") || host === "localhost") {
|
|
91
|
+
return "Use a public address. Private, local, and IP addresses are not reachable from here.";
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function readSkillFrontmatter(content) {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = parseSkillFrontmatter(content.replace(/\r\n/g, "\n"));
|
|
99
|
+
} catch {
|
|
100
|
+
return { ok: false, message: "The file has malformed frontmatter. A skill starts with a --- block that sets name and description." };
|
|
101
|
+
}
|
|
102
|
+
const name = parsed.frontmatter.name?.trim();
|
|
103
|
+
const description = parsed.frontmatter.description?.trim();
|
|
104
|
+
if (!name || !description) {
|
|
105
|
+
return { ok: false, message: "This file is not a skill. A skill file starts with frontmatter that sets name and description." };
|
|
106
|
+
}
|
|
107
|
+
return { ok: true, name, description };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
PROFILE_EDITOR_ROUTES,
|
|
112
|
+
createProfileEditorClient,
|
|
113
|
+
parseGitHubLocation,
|
|
114
|
+
isCommitSha,
|
|
115
|
+
publicHttpsUrlProblem,
|
|
116
|
+
readSkillFrontmatter
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=chunk-B7CL7ENS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/profile-editor/index.ts"],"sourcesContent":["/**\n * Shared contract between the profile editor and the product server that\n * checks what an edit points at: GitHub skill and file sources, and MCP\n * servers. The editor never talks to GitHub or an MCP server itself; the\n * product authenticates the request, picks the credential, and answers through\n * `./profile-editor/server`. This module is browser-safe: types, the wire\n * format, and a fetch client for the product's route.\n */\nimport type { AgentProfileMcpServer } from '@tangle-network/agent-interface/profile'\nimport { parseSkillFrontmatter } from '../skills/frontmatter'\n\n/** Why a GitHub source cannot be used. Each one renders its own message and next step. */\nexport type GitHubSourceProblem =\n /** The workspace has no usable GitHub connection. */\n | 'not-connected'\n /** GitHub answered 404 for the repository: it does not exist, or this connection cannot see it. */\n | 'repository-not-found'\n /** GitHub refused the connection (401/403), for example an expired token or SSO enforcement. */\n | 'no-access'\n /** The commit or branch does not exist in the repository. */\n | 'ref-not-found'\n /** No file exists at the path in the chosen commit. */\n | 'path-not-found'\n /** The path names a folder without a skill file in it. */\n | 'not-a-file'\n /** The file is not an Agent Skill: it lacks `name` and `description` frontmatter. */\n | 'not-a-skill'\n /** The file is larger than the product accepts, or is not UTF-8 text. */\n | 'unsupported-file'\n | 'rate-limited'\n /** GitHub or the product's connection service did not answer, or the operation is not offered. */\n | 'unavailable'\n\nexport interface GitHubSourceFailure {\n ok: false\n problem: GitHubSourceProblem\n /** User-facing explanation with the next step. */\n message: string\n}\n\nexport type GitHubSourceOutcome<T> = { ok: true; value: T } | GitHubSourceFailure\n\nexport interface GitHubRepositorySummary {\n /** `owner/repo`. */\n fullName: string\n private: boolean\n defaultBranch: string\n description?: string\n}\n\nexport interface GitHubCommitSummary {\n /** Full 40-character commit SHA. */\n sha: string\n /** The branch the commit was resolved from, when it was resolved from one. */\n branch?: string\n committedAt?: string\n message?: string\n}\n\nexport interface GitHubFileEntry {\n path: string\n size?: number\n}\n\nexport interface GitHubFileList {\n commit: GitHubCommitSummary\n files: GitHubFileEntry[]\n /** GitHub truncated the listing; paths not listed can still be typed. */\n truncated: boolean\n}\n\nexport type GitHubSourcePurpose = 'skill' | 'file'\n\nexport interface GitHubSourceRequest {\n repository: string\n path: string\n /** Full commit SHA the source is pinned to. */\n commit: string\n purpose: GitHubSourcePurpose\n}\n\nexport interface GitHubSourceCheck {\n repository: string\n /** The checked path. A skill folder resolves to its `SKILL.md`. */\n path: string\n commit: GitHubCommitSummary\n size: number\n /** The file's UTF-8 text, for products that store sources inline. */\n content: string\n /** Frontmatter of a skill file. */\n skill?: { name: string; description: string }\n}\n\n/** GitHub lookups the editor needs, answered by the product with the workspace's connection. */\nexport interface ProfileEditorGitHubPort {\n /** Repositories the connection can read, most recently updated first. */\n repositories(signal?: AbortSignal): Promise<GitHubSourceOutcome<{ repositories: GitHubRepositorySummary[] }>>\n /** The repository and the head commit of its default branch. */\n latest(repository: string, signal?: AbortSignal): Promise<GitHubSourceOutcome<{ repository: GitHubRepositorySummary; commit: GitHubCommitSummary }>>\n /** Confirm a commit SHA exists in the repository. */\n commit(repository: string, sha: string, signal?: AbortSignal): Promise<GitHubSourceOutcome<GitHubCommitSummary>>\n /** Files in the repository at a commit, for path suggestions. */\n files(repository: string, commit: string, signal?: AbortSignal): Promise<GitHubSourceOutcome<GitHubFileList>>\n /** Read and validate the source the editor is about to add. */\n check(request: GitHubSourceRequest, signal?: AbortSignal): Promise<GitHubSourceOutcome<GitHubSourceCheck>>\n}\n\n/** Why an MCP server check failed. */\nexport type McpHealthProblem =\n /** The URL is malformed or uses a scheme the product does not accept. */\n | 'invalid-url'\n /** The product does not connect to this address, for example a private network or plain HTTP. */\n | 'blocked-url'\n /** This product checks remote servers only; a local command is checked when the agent starts it. */\n | 'not-checkable'\n | 'unreachable'\n | 'timeout'\n /** The server asked for credentials the check does not send. */\n | 'auth-required'\n /** The server answered, but not with the MCP protocol. */\n | 'protocol-error'\n | 'unavailable'\n\nexport interface McpTool {\n name: string\n description?: string\n}\n\nexport type McpHealth =\n | { ok: true; tools: McpTool[]; serverName?: string; serverVersion?: string; latencyMs: number; checkedAt: string }\n | { ok: false; problem: McpHealthProblem; message: string; status?: number; checkedAt: string }\n\n/** Connects to an MCP server and lists its tools. The product decides which addresses it will reach. */\nexport interface ProfileEditorMcpPort {\n check(server: AgentProfileMcpServer, signal?: AbortSignal): Promise<McpHealth>\n}\n\n/** The product route's subpaths, relative to the endpoint passed to {@link createProfileEditorClient}. */\nexport const PROFILE_EDITOR_ROUTES = {\n repositories: 'github/repositories',\n latest: 'github/latest',\n commit: 'github/commit',\n files: 'github/files',\n check: 'github/check',\n mcpCheck: 'mcp/check',\n} as const\n\nexport interface ProfileEditorClient {\n github: ProfileEditorGitHubPort\n mcp: ProfileEditorMcpPort\n}\n\nexport interface ProfileEditorClientOptions {\n /** The product route that serves `./profile-editor/server`, for example `/api/workspaces/w1/profile-editor`. */\n endpoint: string\n fetch?: typeof fetch\n}\n\nfunction unavailable(message: string): GitHubSourceFailure {\n return { ok: false, problem: 'unavailable', message }\n}\n\n/** Ports backed by the product route. A transport failure becomes an `unavailable` outcome, never a throw. */\nexport function createProfileEditorClient({ endpoint, fetch: fetchImpl }: ProfileEditorClientOptions): ProfileEditorClient {\n const base = endpoint.replace(/\\/+$/, '')\n const send = fetchImpl ?? ((input: RequestInfo | URL, init?: RequestInit) => globalThis.fetch(input, init))\n\n async function call<T>(path: string, init: RequestInit & { query?: Record<string, string> }, failure: (message: string) => T): Promise<T> {\n const query = init.query ? '?' + new URLSearchParams(init.query).toString() : ''\n try {\n const response = await send(`${base}/${path}${query}`, {\n method: init.method ?? 'GET', signal: init.signal, credentials: 'same-origin',\n headers: init.body ? { 'Content-Type': 'application/json' } : undefined, body: init.body,\n })\n const body = await response.json().catch(() => null) as T | { error?: string } | null\n if (response.ok && body && typeof body === 'object' && 'ok' in body) return body as T\n const detail = body && typeof body === 'object' && 'error' in body && typeof body.error === 'string' ? body.error : ''\n if (response.status === 401 || response.status === 403) return failure(detail || 'You do not have access to check sources for this workspace.')\n return failure(detail || `The source check could not complete (HTTP ${response.status}).`)\n } catch (cause) {\n if (init.signal?.aborted) throw cause\n return failure('The source check could not reach the server. Check your connection and try again.')\n }\n }\n\n const github: ProfileEditorGitHubPort = {\n repositories: signal => call(PROFILE_EDITOR_ROUTES.repositories, { signal }, unavailable),\n latest: (repository, signal) => call(PROFILE_EDITOR_ROUTES.latest, { signal, query: { repository } }, unavailable),\n commit: (repository, sha, signal) => call(PROFILE_EDITOR_ROUTES.commit, { signal, query: { repository, sha } }, unavailable),\n files: (repository, commit, signal) => call(PROFILE_EDITOR_ROUTES.files, { signal, query: { repository, commit } }, unavailable),\n check: (request, signal) => call(PROFILE_EDITOR_ROUTES.check, { signal, method: 'POST', body: JSON.stringify(request) }, unavailable),\n }\n const mcp: ProfileEditorMcpPort = {\n check: (server, signal) => call(PROFILE_EDITOR_ROUTES.mcpCheck, { signal, method: 'POST', body: JSON.stringify({ server }) },\n (message): McpHealth => ({ ok: false, problem: 'unavailable', message, checkedAt: new Date().toISOString() })),\n }\n return { github, mcp }\n}\n\nconst REPOSITORY_SEGMENT = /^[A-Za-z0-9_.-]{1,100}$/\n\n/**\n * Normalize what a person types or pastes into `owner/repo`: a bare name pair,\n * a `github.com` URL (including `/tree/` and `/blob/` links), or an SSH remote.\n * Returns the path and commit-ish a link carries too, so pasting a file link\n * fills every field. Null when the text names no repository.\n */\nexport function parseGitHubLocation(input: string): { repository: string; ref?: string; path?: string } | null {\n let text = input.trim()\n if (!text) return null\n const ssh = /^git@github\\.com:(.+?)(?:\\.git)?$/i.exec(text)\n if (ssh) text = ssh[1]!\n else if (/^(https?:\\/\\/)?(www\\.)?github\\.com\\//i.test(text)) {\n try {\n const url = new URL(/^https?:/i.test(text) ? text : 'https://' + text)\n text = url.pathname.replace(/^\\/+/, '').replace(/\\.git$/, '')\n } catch { return null }\n }\n const [owner, repo, kind, ref, ...rest] = text.split('/').filter(Boolean)\n if (!owner || !repo || !REPOSITORY_SEGMENT.test(owner) || !REPOSITORY_SEGMENT.test(repo) || owner === '.' || owner === '..' || repo === '.' || repo === '..') return null\n const repository = `${owner}/${repo.replace(/\\.git$/, '')}`\n if ((kind === 'tree' || kind === 'blob') && ref) return { repository, ref, ...(rest.length ? { path: rest.join('/') } : {}) }\n return kind ? null : { repository }\n}\n\nexport function isCommitSha(value: string): boolean {\n return /^[0-9a-f]{40}$/i.test(value)\n}\n\n/**\n * The address policy for products that connect only to public HTTPS servers:\n * no credentials in the URL, no IP literals, and no single-label, `.local` or\n * `.internal` hosts. Returns the reason an address is refused, or null.\n */\nexport function publicHttpsUrlProblem(value: string): string | null {\n let url: URL\n try { url = new URL(value) } catch { return 'Enter a full URL, such as https://example.com/mcp.' }\n if (url.protocol !== 'https:') return 'Use a public HTTPS address that starts with https://.'\n if (url.username || url.password) return 'Remove the credentials from the URL. Use a secret reference in a header instead.'\n if (url.search || url.hash) return 'Remove the query and fragment from the URL. Send credentials as a secret reference in a header.'\n const host = url.hostname.toLowerCase()\n if (!host.includes('.') || /^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(host) || host.startsWith('[') || host.endsWith('.local') ||\n host.endsWith('.internal') || host.endsWith('.localhost') || host === 'localhost') {\n return 'Use a public address. Private, local, and IP addresses are not reachable from here.'\n }\n return null\n}\n\n/** Frontmatter `name` and `description` of an Agent Skill, or the reason the text is not one. */\nexport function readSkillFrontmatter(content: string): { ok: true; name: string; description: string } | { ok: false; message: string } {\n let parsed: ReturnType<typeof parseSkillFrontmatter>\n try { parsed = parseSkillFrontmatter(content.replace(/\\r\\n/g, '\\n')) } catch {\n return { ok: false, message: 'The file has malformed frontmatter. A skill starts with a --- block that sets name and description.' }\n }\n const name = parsed.frontmatter.name?.trim()\n const description = parsed.frontmatter.description?.trim()\n if (!name || !description) {\n return { ok: false, message: 'This file is not a skill. A skill file starts with frontmatter that sets name and description.' }\n }\n return { ok: true, name, description }\n}\n"],"mappings":";;;;;AA0IO,IAAM,wBAAwB;AAAA,EACnC,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AACZ;AAaA,SAAS,YAAY,SAAsC;AACzD,SAAO,EAAE,IAAI,OAAO,SAAS,eAAe,QAAQ;AACtD;AAGO,SAAS,0BAA0B,EAAE,UAAU,OAAO,UAAU,GAAoD;AACzH,QAAM,OAAO,SAAS,QAAQ,QAAQ,EAAE;AACxC,QAAM,OAAO,cAAc,CAAC,OAA0B,SAAuB,WAAW,MAAM,OAAO,IAAI;AAEzG,iBAAe,KAAQ,MAAc,MAAwD,SAA6C;AACxI,UAAM,QAAQ,KAAK,QAAQ,MAAM,IAAI,gBAAgB,KAAK,KAAK,EAAE,SAAS,IAAI;AAC9E,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,IAAI;AAAA,QACrD,QAAQ,KAAK,UAAU;AAAA,QAAO,QAAQ,KAAK;AAAA,QAAQ,aAAa;AAAA,QA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