raga-cli 0.8.0 → 0.10.0
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/CHANGELOG.md +29 -0
- package/README.md +33 -5
- package/bundled-skills/README.md +2 -2
- package/bundled-skills/bundle.json +75 -9
- package/bundled-skills/docs/guide/01-setup.md +1 -1
- package/bundled-skills/skills/bend/SKILL.md +58 -0
- package/bundled-skills/skills/bend/bend_tool.py +144 -0
- package/bundled-skills/skills/peak/SKILL.md +2 -2
- package/bundled-skills/skills/peak/references/peak-setup/SKILL.md +1 -1
- package/bundled-skills/skills/peak/references/raga-runtime/SKILL.md +20 -6
- package/bundled-skills/skills/peak/references/raga-runtime/raga_runtime.py +24 -6
- package/bundled-skills/skills/raga-artifacts/SKILL.md +117 -0
- package/bundled-skills/skills/raga-artifacts/artifact.mjs +259 -0
- package/bundled-skills/skills/raga-artifacts/artifact_tool.py +55 -0
- package/bundled-skills/skills/raga-artifacts/diagrams.md +641 -0
- package/bundled-skills/skills/raga-artifacts/templates/doc.html +124 -0
- package/bundled-skills/skills/raga-artifacts/templates/slides.html +138 -0
- package/dist/bundle/chunks/agent-attach-ZCS2QGIU.js +9 -0
- package/dist/bundle/chunks/anthropic.js +1 -8
- package/dist/bundle/chunks/chunk-4OPO7UJ6.js +4 -0
- package/dist/bundle/chunks/{chunk-IOPE2TJ4.js → chunk-A4342OQJ.js} +16 -16
- package/dist/bundle/chunks/{chunk-YMZUNB25.js → chunk-ABE5B2U7.js} +1 -1
- package/dist/bundle/chunks/{chunk-P2QCWBFM.js → chunk-D2SEW6VC.js} +1 -1
- package/dist/bundle/chunks/chunk-FTQDEUXY.js +242 -0
- package/dist/bundle/chunks/chunk-HRI5E2Y3.js +2 -0
- package/dist/bundle/chunks/{chunk-UDT647VB.js → chunk-JNHUOSVT.js} +2 -9
- package/dist/bundle/chunks/chunk-K22YTJFL.js +3 -0
- package/dist/bundle/chunks/chunk-MXJNFS34.js +47 -0
- package/dist/bundle/chunks/{chunk-J22MF7YW.js → chunk-NXGZMUQX.js} +3 -48
- package/dist/bundle/chunks/{chunk-3EGDWOKT.js → chunk-NYFFOHME.js} +1 -1
- package/dist/bundle/chunks/chunk-P2EB6CEF.js +6 -0
- package/dist/bundle/chunks/{chunk-KNY3PXQI.js → chunk-SK25JXS4.js} +1 -1
- package/dist/bundle/chunks/chunk-VEV3PRRP.js +1358 -0
- package/dist/bundle/chunks/chunk-XBBS7V4D.js +2 -0
- package/dist/bundle/chunks/{cli-4P6FVVLT.js → cli-XZ774I3U.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-65VIC4G2.js → easter-egg-3d-XWC5XWQO.js} +1 -1
- package/dist/bundle/chunks/{execute-3H5WKMA3.js → execute-7BWE4ZV3.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -8
- package/dist/bundle/chunks/openai-codex.js +1 -8
- package/dist/bundle/chunks/openrouter.js +1 -8
- package/dist/bundle/chunks/radius.js +1 -8
- package/dist/bundle/chunks/runtime-K76CFDG5.js +2 -0
- package/dist/bundle/chunks/virtual-modules-YAFG26WW.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/raga-runtime.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/docs/cli.md +8 -0
- package/docs/compaction.md +26 -0
- package/docs/sdk.md +2 -1
- package/docs/settings.md +1 -0
- package/package.json +1 -1
- package/python/raga_rlm/__init__.py +30 -6
- package/python/raga_rlm/mlx_models.py +265 -0
- package/schemas/keybindings.schema.json +84 -0
- package/schemas/settings.schema.json +74 -1
- package/schemas/theme.schema.json +2 -2
- package/dist/bundle/chunks/chunk-AI2NMHE7.js +0 -1567
- package/dist/bundle/chunks/chunk-C4IJNE7U.js +0 -2
- package/dist/bundle/chunks/chunk-RFPFZTK2.js +0 -7
- package/dist/bundle/chunks/chunk-RP2WKNT7.js +0 -4
- package/dist/bundle/chunks/runtime-435R6IKY.js +0 -2
- package/dist/bundle/chunks/virtual-modules-U3JBUDP7.js +0 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="light">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Document title</title>
|
|
6
|
+
<style>
|
|
7
|
+
|
|
8
|
+
/* Theme. Change these variables to restyle text, slides, code, and Pele diagrams together. */
|
|
9
|
+
:root {
|
|
10
|
+
--font-sans: "Inter", "SF Pro Text", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
|
11
|
+
--font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
|
|
12
|
+
--bg: #fbfaf7;
|
|
13
|
+
--fg: #17171a;
|
|
14
|
+
--muted: #6b6b73;
|
|
15
|
+
--surface: #f1efe9;
|
|
16
|
+
--surface-alt: #e6e3da;
|
|
17
|
+
--border: #d8d4c8;
|
|
18
|
+
--accent: #3554d1;
|
|
19
|
+
--accent-soft: #e4e9fb;
|
|
20
|
+
--good: #1f8a5b;
|
|
21
|
+
--warn: #b7791f;
|
|
22
|
+
--bad: #c2412d;
|
|
23
|
+
}
|
|
24
|
+
:root[data-theme="dark"] {
|
|
25
|
+
--bg: #111114;
|
|
26
|
+
--fg: #ececf1;
|
|
27
|
+
--muted: #9a9aa6;
|
|
28
|
+
--surface: #1b1b20;
|
|
29
|
+
--surface-alt: #26262d;
|
|
30
|
+
--border: #34343c;
|
|
31
|
+
--accent: #7b93ff;
|
|
32
|
+
--accent-soft: #1e2440;
|
|
33
|
+
--good: #4cc38a;
|
|
34
|
+
--warn: #e0a84a;
|
|
35
|
+
--bad: #ef6f5c;
|
|
36
|
+
}
|
|
37
|
+
:root[data-theme="ink"] {
|
|
38
|
+
--bg: #ffffff;
|
|
39
|
+
--fg: #0b0b0c;
|
|
40
|
+
--muted: #5c5c63;
|
|
41
|
+
--surface: #f4f4f5;
|
|
42
|
+
--surface-alt: #e8e8ea;
|
|
43
|
+
--border: #d4d4d8;
|
|
44
|
+
--accent: #0b0b0c;
|
|
45
|
+
--accent-soft: #f0f0f1;
|
|
46
|
+
}
|
|
47
|
+
* { box-sizing: border-box; }
|
|
48
|
+
html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
49
|
+
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; }
|
|
50
|
+
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 0.4em; font-weight: 700; }
|
|
51
|
+
p, li { line-height: 1.55; }
|
|
52
|
+
a { color: var(--accent); text-decoration: none; }
|
|
53
|
+
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 0.08em 0.35em; }
|
|
54
|
+
pre.code { margin: 0; padding: 18px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; white-space: pre-wrap; }
|
|
55
|
+
pre.code code { background: none; border: 0; padding: 0; font-size: 0.82em; line-height: 1.6; }
|
|
56
|
+
.hljs-keyword, .hljs-built_in, .hljs-selector-tag { color: var(--accent); font-weight: 600; }
|
|
57
|
+
.hljs-string, .hljs-attr, .hljs-template-tag { color: var(--good); }
|
|
58
|
+
.hljs-number, .hljs-literal, .hljs-symbol { color: var(--warn); }
|
|
59
|
+
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
|
|
60
|
+
.hljs-title, .hljs-function .hljs-title, .hljs-class .hljs-title { color: var(--bad); }
|
|
61
|
+
table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
|
|
62
|
+
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
|
|
63
|
+
th { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
|
|
64
|
+
.kicker { font-size: 0.8em; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.8em; }
|
|
65
|
+
.muted { color: var(--muted); }
|
|
66
|
+
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 14px 18px; border-radius: 0 10px 10px 0; }
|
|
67
|
+
.callout.good { border-color: var(--good); }
|
|
68
|
+
.callout.warn { border-color: var(--warn); }
|
|
69
|
+
.callout.bad { border-color: var(--bad); }
|
|
70
|
+
.tag { display: inline-block; font-size: 0.75em; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-alt); color: var(--fg); }
|
|
71
|
+
.cols { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 40px; align-items: start; }
|
|
72
|
+
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; }
|
|
73
|
+
.stat .value { font-size: 3.2em; font-weight: 750; letter-spacing: -0.04em; line-height: 1; }
|
|
74
|
+
.stat .label { color: var(--muted); margin-top: 0.4em; }
|
|
75
|
+
figure.diagram { margin: 0; display: flex; justify-content: center; }
|
|
76
|
+
figure.diagram svg { max-width: 100%; height: auto; }
|
|
77
|
+
figcaption { color: var(--muted); font-size: 0.85em; text-align: center; margin-top: 0.6em; }
|
|
78
|
+
/* Pele reads these variables, so diagrams follow the theme. */
|
|
79
|
+
.pele {
|
|
80
|
+
--pele-bg: var(--bg); --pele-fg: var(--fg); --pele-muted: var(--muted); --pele-line: var(--muted);
|
|
81
|
+
--pele-surface: var(--surface); --pele-surface-alt: var(--surface-alt); --pele-border: var(--border);
|
|
82
|
+
--pele-accent: var(--accent); --pele-critical: var(--bad); --pele-font: var(--font-sans); --pele-font-mono: var(--font-mono);
|
|
83
|
+
--pele-radius: 8px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Document: A4 pages. Use .page-break before a section that must start on a new page. */
|
|
87
|
+
@page { size: A4; margin: 20mm 18mm; }
|
|
88
|
+
body { font-size: 11pt; }
|
|
89
|
+
main { max-width: 760px; margin: 0 auto; }
|
|
90
|
+
header.cover { padding: 56px 0 36px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
|
|
91
|
+
header.cover h1 { font-size: 2.6em; max-width: 14em; }
|
|
92
|
+
header.cover .meta { color: var(--muted); display: flex; gap: 24px; flex-wrap: wrap; font-size: 0.92em; }
|
|
93
|
+
h2 { font-size: 1.55em; margin-top: 1.6em; }
|
|
94
|
+
h3 { font-size: 1.15em; margin-top: 1.3em; }
|
|
95
|
+
h2, h3 { break-after: avoid; }
|
|
96
|
+
figure, table, pre.code, .callout, .card { break-inside: avoid; margin: 1.2em 0; }
|
|
97
|
+
.page-break { break-before: page; }
|
|
98
|
+
.summary { font-size: 1.12em; line-height: 1.6; }
|
|
99
|
+
@media screen { body { padding: 40px 24px; } }
|
|
100
|
+
</style>
|
|
101
|
+
</head>
|
|
102
|
+
<body>
|
|
103
|
+
<main>
|
|
104
|
+
|
|
105
|
+
<header class="cover">
|
|
106
|
+
<div class="kicker">Proposal</div>
|
|
107
|
+
<h1>Document title that states the point</h1>
|
|
108
|
+
<div class="meta"><span>Author</span><span>Month Year</span><span>Status: Draft</span></div>
|
|
109
|
+
</header>
|
|
110
|
+
|
|
111
|
+
<p class="summary">Two or three sentences: the problem, what you propose, and what you need from the reader.</p>
|
|
112
|
+
|
|
113
|
+
<h2>Section title</h2>
|
|
114
|
+
<p>Write short paragraphs. Use a table, a diagram, or a callout when it saves the reader time.</p>
|
|
115
|
+
|
|
116
|
+
<pre class="mermaid">
|
|
117
|
+
sequenceDiagram
|
|
118
|
+
Client->>API: Request
|
|
119
|
+
API-->>Client: Response
|
|
120
|
+
</pre>
|
|
121
|
+
|
|
122
|
+
</main>
|
|
123
|
+
</body>
|
|
124
|
+
</html>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="light">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Deck title</title>
|
|
6
|
+
<style>
|
|
7
|
+
|
|
8
|
+
/* Theme. Change these variables to restyle text, slides, code, and Pele diagrams together. */
|
|
9
|
+
:root {
|
|
10
|
+
--font-sans: "Inter", "SF Pro Text", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
|
11
|
+
--font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
|
|
12
|
+
--bg: #fbfaf7;
|
|
13
|
+
--fg: #17171a;
|
|
14
|
+
--muted: #6b6b73;
|
|
15
|
+
--surface: #f1efe9;
|
|
16
|
+
--surface-alt: #e6e3da;
|
|
17
|
+
--border: #d8d4c8;
|
|
18
|
+
--accent: #3554d1;
|
|
19
|
+
--accent-soft: #e4e9fb;
|
|
20
|
+
--good: #1f8a5b;
|
|
21
|
+
--warn: #b7791f;
|
|
22
|
+
--bad: #c2412d;
|
|
23
|
+
}
|
|
24
|
+
:root[data-theme="dark"] {
|
|
25
|
+
--bg: #111114;
|
|
26
|
+
--fg: #ececf1;
|
|
27
|
+
--muted: #9a9aa6;
|
|
28
|
+
--surface: #1b1b20;
|
|
29
|
+
--surface-alt: #26262d;
|
|
30
|
+
--border: #34343c;
|
|
31
|
+
--accent: #7b93ff;
|
|
32
|
+
--accent-soft: #1e2440;
|
|
33
|
+
--good: #4cc38a;
|
|
34
|
+
--warn: #e0a84a;
|
|
35
|
+
--bad: #ef6f5c;
|
|
36
|
+
}
|
|
37
|
+
:root[data-theme="ink"] {
|
|
38
|
+
--bg: #ffffff;
|
|
39
|
+
--fg: #0b0b0c;
|
|
40
|
+
--muted: #5c5c63;
|
|
41
|
+
--surface: #f4f4f5;
|
|
42
|
+
--surface-alt: #e8e8ea;
|
|
43
|
+
--border: #d4d4d8;
|
|
44
|
+
--accent: #0b0b0c;
|
|
45
|
+
--accent-soft: #f0f0f1;
|
|
46
|
+
}
|
|
47
|
+
* { box-sizing: border-box; }
|
|
48
|
+
html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
49
|
+
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; }
|
|
50
|
+
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 0.4em; font-weight: 700; }
|
|
51
|
+
p, li { line-height: 1.55; }
|
|
52
|
+
a { color: var(--accent); text-decoration: none; }
|
|
53
|
+
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 0.08em 0.35em; }
|
|
54
|
+
pre.code { margin: 0; padding: 18px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; white-space: pre-wrap; }
|
|
55
|
+
pre.code code { background: none; border: 0; padding: 0; font-size: 0.82em; line-height: 1.6; }
|
|
56
|
+
.hljs-keyword, .hljs-built_in, .hljs-selector-tag { color: var(--accent); font-weight: 600; }
|
|
57
|
+
.hljs-string, .hljs-attr, .hljs-template-tag { color: var(--good); }
|
|
58
|
+
.hljs-number, .hljs-literal, .hljs-symbol { color: var(--warn); }
|
|
59
|
+
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
|
|
60
|
+
.hljs-title, .hljs-function .hljs-title, .hljs-class .hljs-title { color: var(--bad); }
|
|
61
|
+
table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
|
|
62
|
+
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
|
|
63
|
+
th { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
|
|
64
|
+
.kicker { font-size: 0.8em; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.8em; }
|
|
65
|
+
.muted { color: var(--muted); }
|
|
66
|
+
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 14px 18px; border-radius: 0 10px 10px 0; }
|
|
67
|
+
.callout.good { border-color: var(--good); }
|
|
68
|
+
.callout.warn { border-color: var(--warn); }
|
|
69
|
+
.callout.bad { border-color: var(--bad); }
|
|
70
|
+
.tag { display: inline-block; font-size: 0.75em; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-alt); color: var(--fg); }
|
|
71
|
+
.cols { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 40px; align-items: start; }
|
|
72
|
+
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; }
|
|
73
|
+
.stat .value { font-size: 3.2em; font-weight: 750; letter-spacing: -0.04em; line-height: 1; }
|
|
74
|
+
.stat .label { color: var(--muted); margin-top: 0.4em; }
|
|
75
|
+
figure.diagram { margin: 0; display: flex; justify-content: center; }
|
|
76
|
+
figure.diagram svg { max-width: 100%; height: auto; }
|
|
77
|
+
figcaption { color: var(--muted); font-size: 0.85em; text-align: center; margin-top: 0.6em; }
|
|
78
|
+
/* Pele reads these variables, so diagrams follow the theme. */
|
|
79
|
+
.pele {
|
|
80
|
+
--pele-bg: var(--bg); --pele-fg: var(--fg); --pele-muted: var(--muted); --pele-line: var(--muted);
|
|
81
|
+
--pele-surface: var(--surface); --pele-surface-alt: var(--surface-alt); --pele-border: var(--border);
|
|
82
|
+
--pele-accent: var(--accent); --pele-critical: var(--bad); --pele-font: var(--font-sans); --pele-font-mono: var(--font-mono);
|
|
83
|
+
--pele-radius: 8px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Slides: 1600x900, one slide per PDF page. Keep each slide's content inside its frame. */
|
|
87
|
+
@page { size: 1600px 900px; margin: 0; }
|
|
88
|
+
body { font-size: 30px; }
|
|
89
|
+
.slide { position: relative; width: 1600px; height: 900px; padding: 96px 120px; overflow: hidden; break-after: page; display: flex; flex-direction: column; justify-content: center; background: var(--bg); }
|
|
90
|
+
.slide h1 { font-size: 2.8em; }
|
|
91
|
+
.slide h2 { font-size: 1.9em; margin-bottom: 0.7em; }
|
|
92
|
+
.slide ul { margin: 0; padding-left: 1.1em; }
|
|
93
|
+
.slide li + li { margin-top: 0.45em; }
|
|
94
|
+
.slide .footer { position: absolute; left: 120px; right: 120px; bottom: 44px; display: flex; justify-content: space-between; font-size: 0.55em; color: var(--muted); }
|
|
95
|
+
.slide.title { justify-content: flex-end; padding-bottom: 140px; }
|
|
96
|
+
.slide.title h1 { font-size: 3.6em; max-width: 13em; }
|
|
97
|
+
.slide.title .subtitle { font-size: 1.15em; color: var(--muted); max-width: 32em; }
|
|
98
|
+
.slide.section { background: var(--accent); color: var(--bg); }
|
|
99
|
+
.slide.section .kicker, .slide.section .footer { color: var(--bg); opacity: 0.75; }
|
|
100
|
+
.slide.statement h2 { font-size: 2.4em; max-width: 18em; }
|
|
101
|
+
.slide figure.diagram svg { max-height: 560px; }
|
|
102
|
+
@media screen {
|
|
103
|
+
body { background: var(--surface-alt); padding: 40px 0; }
|
|
104
|
+
.slide { margin: 0 auto 40px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12); border-radius: 6px; }
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
107
|
+
</head>
|
|
108
|
+
<body>
|
|
109
|
+
|
|
110
|
+
<section class="slide title">
|
|
111
|
+
<div class="kicker">Project · Month Year</div>
|
|
112
|
+
<h1>Deck title that states the point</h1>
|
|
113
|
+
<p class="subtitle">One sentence on what the audience will take away.</p>
|
|
114
|
+
<div class="footer"><span>Author</span><span>1</span></div>
|
|
115
|
+
</section>
|
|
116
|
+
|
|
117
|
+
<section class="slide">
|
|
118
|
+
<div class="kicker">Context</div>
|
|
119
|
+
<h2>A slide title that says the conclusion</h2>
|
|
120
|
+
<ul>
|
|
121
|
+
<li>One idea per bullet, at most five bullets.</li>
|
|
122
|
+
<li>Use a diagram or a number when it explains faster than words.</li>
|
|
123
|
+
</ul>
|
|
124
|
+
<div class="footer"><span>Deck title</span><span>2</span></div>
|
|
125
|
+
</section>
|
|
126
|
+
|
|
127
|
+
<section class="slide">
|
|
128
|
+
<div class="kicker">How it works</div>
|
|
129
|
+
<h2>Diagrams are Mermaid, rendered by Pele</h2>
|
|
130
|
+
<pre class="mermaid">
|
|
131
|
+
flowchart LR
|
|
132
|
+
A[Source] --> B[Build] --> C[PDF]
|
|
133
|
+
</pre>
|
|
134
|
+
<div class="footer"><span>Deck title</span><span>3</span></div>
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
+
import{AssistantMessageComponent,BashExecutionComponent,BranchSummaryMessageComponent,CHILD_AGENT_PROTOCOL_VERSION,CompactionSummaryMessageComponent,CustomEditor,CustomMessageComponent,FORWARDED_CHILD_AGENT_EVENTS,KeybindingsManager,SettingsManager,ToolExecutionComponent,UserMessageComponent,createChatViewport,createInteractiveTui,formatTokens,requestTerminalColors,withBuiltInRenderers}from"./chunk-FTQDEUXY.js";import"./chunk-NXGZMUQX.js";import{Container,SYSTEM_THEME_NAME,Spacer,TruncatedText,VStack,getEditorTheme,getMarkdownTheme,getTerminalTheme,initTheme,isViewportTUI,markTerminalColorsPending,resolveThemeSetting,setCapabilityOverrides,setKeybindings,setTerminalColors,setTheme,theme,truncateToWidth}from"./chunk-A4342OQJ.js";import"./chunk-5AGIVGSV.js";import"./chunk-HRI5E2Y3.js";import"./chunk-K22YTJFL.js";import"./chunk-D2SEW6VC.js";import"./chunk-6QGV3IWD.js";import{getAgentDir}from"./chunk-SK25JXS4.js";import"./chunk-JXWJOIH4.js";import{createConnection}from"node:net";import{stripVTControlCharacters}from"node:util";var AGENT_ATTACH_USAGE="Usage: raga agent-attach --socket <path> --agent <id>",AGENT_ATTACH_DISCONNECTED="Disconnected: the Raga session that owns this subagent ended.",RECONNECT_DELAY_MS=2e3,MAX_SERVER_LINE_CHARS=64*1024*1024,RETRYABLE_CONNECT_ERRORS=new Set(["ECONNREFUSED","ENOENT"]);function parseAgentAttachArgs(args){let values={};for(let index=0;index<args.length;index++){let arg=args[index],key=arg==="--socket"?"socket":arg==="--agent"?"agent":void 0;if(!key)throw new Error(`Unknown option: ${sanitizeTerminalText(arg)}`);if(values[key]!==void 0)throw new Error(`Duplicate option: ${arg}`);let value=args[++index];if(value===void 0||value===""||value.startsWith("--"))throw new Error(`Missing value for ${arg}`);values[key]=value}if(values.socket===void 0)throw new Error("Missing --socket");if(values.agent===void 0)throw new Error("Missing --agent");return{socket:values.socket,agent:values.agent}}function sanitizeTerminalText(text,multiline=!1){return(multiline?text.replace(/\r\n/g,`
|
|
3
|
+
`):text.replace(/[\r\n\t]+/g," ")).replace(/[\x00-\x1f\x7f-\x9f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g,char=>{if(multiline&&(char===`
|
|
4
|
+
`||char===" "))return char;let code=char.charCodeAt(0);return code<=255?`\\x${code.toString(16).padStart(2,"0")}`:`\\u${code.toString(16).padStart(4,"0")}`})}function sanitizeJson(value){if(typeof value=="string")return sanitizeTerminalText(value,!0);if(Array.isArray(value))return value.map(sanitizeJson);if(value&&typeof value=="object"){let result={};for(let[key,item]of Object.entries(value))result[sanitizeTerminalText(key)]=sanitizeJson(item);return result}return value}var isRecord=value=>typeof value=="object"&&value!==null&&!Array.isArray(value),isStringArray=value=>Array.isArray(value)&&value.every(item=>typeof item=="string"),isContent=value=>Array.isArray(value)&&value.every(item=>isRecord(item)&&typeof item.type=="string"),forwardedEvents=new Set(FORWARDED_CHILD_AGENT_EVENTS);function isAgentInfo(value){if(!isRecord(value)||!isRecord(value.usage))return!1;let usage=value.usage;return["id","name","rootSessionId","model","status"].every(key=>typeof value[key]=="string")&&typeof value.turns=="number"&&typeof value.maxTurns=="number"&&["input","output","cost"].every(key=>typeof usage[key]=="number")}function isAgentMessage(value){if(!isRecord(value)||typeof value.role!="string")return!1;switch(value.role){case"assistant":return isContent(value.content)&&value.content.every(block=>block.type!=="toolCall"||typeof block.id=="string"&&typeof block.name=="string");case"toolResult":return typeof value.toolCallId=="string"&&isContent(value.content);case"user":case"custom":return typeof value.content=="string"||isContent(value.content);case"bashExecution":return typeof value.command=="string"&&(value.output===void 0||typeof value.output=="string");default:return!0}}var isToolResult=value=>isRecord(value)&&isContent(value.content);function isForwardedEvent(event){if(typeof event.type!="string"||!forwardedEvents.has(event.type))return!1;switch(event.type){case"queue_update":return isStringArray(event.steering)&&isStringArray(event.followUp);case"message_start":case"message_update":case"message_end":return isAgentMessage(event.message);case"tool_execution_start":return typeof event.toolCallId=="string"&&typeof event.toolName=="string";case"tool_execution_update":return typeof event.toolCallId=="string"&&isToolResult(event.partialResult);case"tool_execution_end":return typeof event.toolCallId=="string"&&isToolResult(event.result);default:return!0}}function stripResultAnsi(result){if(!(!isRecord(result)||!Array.isArray(result.content)))for(let block of result.content)isRecord(block)&&block.type==="text"&&typeof block.text=="string"&&(block.text=stripVTControlCharacters(block.text))}function stripMessageAnsi(message){isRecord(message)&&(message.role==="toolResult"?stripResultAnsi(message):message.role==="bashExecution"&&typeof message.output=="string"&&(message.output=stripVTControlCharacters(message.output)))}function parseServerMessage(line){let raw;try{raw=JSON.parse(line)}catch{return}if(isRecord(raw)){if(Array.isArray(raw.messages))for(let item of raw.messages)stripMessageAnsi(item);isRecord(raw.event)&&(stripMessageAnsi(raw.event.message),stripResultAnsi(raw.event.partialResult),stripResultAnsi(raw.event.result))}let message=sanitizeJson(raw);if(isRecord(message)){switch(message.type){case"welcome":if(!isAgentInfo(message.agent)||!Array.isArray(message.messages)||!message.messages.every(isAgentMessage)||(message.streaming??=null,message.streaming!==null&&!isAgentMessage(message.streaming))||!isStringArray(message.pendingToolCallIds))return;break;case"agent":if(!isAgentInfo(message.agent))return;break;case"event":if(!isRecord(message.event)||!isForwardedEvent(message.event))return;break;case"error":if(typeof message.message!="string")return;break;default:return}return message}}function createLineReader(maxChars,onLine){let parts=[],length=0;return chunk=>{let start=0;for(let index=chunk.indexOf(`
|
|
5
|
+
`);index!==-1;index=chunk.indexOf(`
|
|
6
|
+
`,start)){if(length+index-start>maxChars)return!1;let piece=chunk.slice(start,index),line=parts.length>0?parts.join("")+piece:piece;parts=[],length=0,start=index+1,onLine(line)}if(start<chunk.length){if(length+=chunk.length-start,length>maxChars)return!1;parts.push(chunk.slice(start))}return!0}}var statusText=agent=>agent.busy&&agent.status!=="running"?`${agent.status}, responding`:agent.status;function formatAttachHeader(agent){return sanitizeTerminalText(`${agent.name} \xB7 ${statusText(agent)} \xB7 ${agent.model} \xB7 subagent of ${agent.rootSessionId.slice(0,8)}`)}function formatAttachFooter(agent){let usage=agent.usage;return sanitizeTerminalText(`${agent.model} \xB7 \u2191${formatTokens(usage.input)} \u2193${formatTokens(usage.output)} tokens \xB7 $${usage.cost.toFixed(3)} \xB7 turns ${agent.turns}/${agent.maxTurns} \xB7 ${statusText(agent)}`)}var Line=class{build;constructor(build){this.build=build}render(width){let text=this.build();return text?[truncateToWidth(text,Math.max(0,width))]:[]}invalidate(){}},AgentAttachView=class{header;chat=new Container;pending=new Container;status;footer;agent;connection="connecting";ui;settings;notice;lastError;fatalError;expanded=!1;streamingComponent;pendingTools=new Map;constructor(ui,settings={}){this.ui=ui,this.settings=settings,this.header=new Line(()=>this.agent?theme.bold(theme.fg("accent",formatAttachHeader(this.agent))):theme.fg("dim","Connecting...")),this.status=new Line(()=>this.connection==="failed"?theme.fg("error",`Error: ${this.fatalError??""}`):this.connection==="disconnected"?theme.fg("warning",AGENT_ATTACH_DISCONNECTED):this.notice?theme.fg(this.notice.color,this.notice.text):""),this.footer=new Line(()=>this.agent?theme.fg("dim",formatAttachFooter(this.agent)):"")}setNotice(text,color="dim"){this.notice=text===void 0?void 0:{text:sanitizeTerminalText(text),color},this.ui.requestRender()}setConnected(connected){this.connection!=="failed"&&(this.connection=connected?"connected":"disconnected",this.ui.requestRender())}setFailed(message){this.connection="failed",this.fatalError=sanitizeTerminalText(message),this.ui.requestRender()}toggleExpanded(){this.expanded=!this.expanded;for(let child of this.chat.children)(child instanceof ToolExecutionComponent||child instanceof CustomMessageComponent||child instanceof BashExecutionComponent||child instanceof CompactionSummaryMessageComponent||child instanceof BranchSummaryMessageComponent)&&child.setExpanded(this.expanded);this.ui.requestRender()}apply(message){try{this.applyMessage(message)}catch(error){this.setNotice(`Could not show a server ${message.type} message: ${error instanceof Error?error.message:String(error)}`,"error")}this.ui.requestRender()}applyMessage(message){switch(message.type){case"welcome":this.agent=message.agent,this.notice=void 0,this.lastError=void 0,this.renderWelcome(message.messages,message.streaming,message.pendingToolCallIds);break;case"agent":this.agent=message.agent;break;case"event":this.handleEvent(message.event);break;case"error":if(message.message!==this.lastError){this.lastError=message.message,this.chat.addChild(new Spacer(1));let text=sanitizeTerminalText(message.message);this.chat.addChild(new TruncatedText(theme.fg("error",`Error: ${text}`),1,0))}break}}markdownTheme(){return{...getMarkdownTheme(),codeBlockIndent:this.settings.codeBlockIndent??" "}}outputPad(){return this.settings.outputPad??1}createToolComponent(name,id,args){let component=new ToolExecutionComponent(name,id,args,{showImages:this.settings.showImages??!0,imageWidthCells:this.settings.imageWidthCells,outputPad:this.outputPad()},withBuiltInRenderers(name,void 0),this.ui,this.settings.cwd??process.cwd());return component.setExpanded(this.expanded),this.chat.addChild(component),component}createAssistantComponent(message){return new AssistantMessageComponent(message,this.settings.hideThinkingBlock??!1,this.markdownTheme(),"Thinking...",this.outputPad())}renderWelcome(messages,streaming,pendingIds){this.chat.clear(),this.pending.clear(),this.pendingTools.clear(),this.streamingComponent=void 0;let rendered=new Map;for(let message of messages)if(message.role==="assistant"){this.addMessage(message);for(let content of message.content){if(content.type!=="toolCall")continue;let component=this.createToolComponent(content.name,content.id,content.arguments);if(message.stopReason==="aborted"||message.stopReason==="error"){let text=message.stopReason==="aborted"?"Operation aborted":message.errorMessage||"Error";component.updateResult({content:[{type:"text",text}],isError:!0})}else rendered.set(content.id,component)}}else if(message.role==="toolResult"){let component=rendered.get(message.toolCallId);component&&(component.updateResult(message),rendered.delete(message.toolCallId))}else this.addMessage(message);for(let[id,component]of rendered)this.pendingTools.set(id,component);streaming?.role==="assistant"&&(this.startStreaming(streaming),this.updateStreaming(streaming));for(let id of pendingIds)this.pendingTools.get(id)?.markExecutionStarted()}startStreaming(message){this.streamingComponent=this.createAssistantComponent(),this.chat.addChild(this.streamingComponent),this.streamingComponent.updateContent(message,!0)}updateStreaming(message){if(this.streamingComponent){this.streamingComponent.updateContent(message,!0);for(let content of message.content){if(content.type!=="toolCall")continue;let existing=this.pendingTools.get(content.id);existing?existing.updateArgs(content.arguments):this.pendingTools.set(content.id,this.createToolComponent(content.name,content.id,content.arguments))}}}handleEvent(event){switch(event.type){case"agent_start":this.pendingTools.clear();break;case"queue_update":if(this.pending.clear(),event.steering.length>0||event.followUp.length>0){this.pending.addChild(new Spacer(1));for(let text of event.steering){let line=sanitizeTerminalText(text);this.pending.addChild(new TruncatedText(theme.fg("dim",`Steering: ${line}`),1,0))}for(let text of event.followUp){let line=sanitizeTerminalText(text);this.pending.addChild(new TruncatedText(theme.fg("dim",`Follow-up: ${line}`),1,0))}}break;case"message_start":event.message.role==="custom"||event.message.role==="user"?this.addMessage(event.message):event.message.role==="assistant"&&this.startStreaming(event.message);break;case"message_update":event.message.role==="assistant"&&this.updateStreaming(event.message);break;case"message_end":{let message=event.message;if(message.role!=="assistant"||!this.streamingComponent)break;if(message.stopReason==="aborted"&&(message.errorMessage="Operation aborted"),this.streamingComponent.updateContent(message,!1),message.stopReason==="aborted"||message.stopReason==="error"){let text=message.errorMessage||"Error";for(let component of this.pendingTools.values())component.updateResult({content:[{type:"text",text}],isError:!0});this.pendingTools.clear()}else for(let component of this.pendingTools.values())component.setArgsComplete();this.streamingComponent=void 0;break}case"tool_execution_start":{if(event.parentToolCallId)break;let component=this.pendingTools.get(event.toolCallId);component||(component=this.createToolComponent(event.toolName,event.toolCallId,event.args),this.pendingTools.set(event.toolCallId,component)),component.markExecutionStarted();break}case"tool_execution_update":this.pendingTools.get(event.toolCallId)?.updateResult({...event.partialResult,isError:!1},!0);break;case"tool_execution_end":{let component=this.pendingTools.get(event.toolCallId);component&&(component.updateResult({...event.result,isError:event.isError,durationMs:event.durationMs}),this.pendingTools.delete(event.toolCallId));break}case"agent_end":this.streamingComponent&&(this.chat.removeChild(this.streamingComponent),this.streamingComponent=void 0),this.pendingTools.clear();break;case"turn_start":case"turn_end":break}}addMessage(message){let pad=this.outputPad();switch(message.role){case"bashExecution":{let component=new BashExecutionComponent(message.command,this.ui,message.excludeFromContext,pad);message.output&&component.appendOutput(message.output),component.setComplete(message.exitCode,message.cancelled,message.truncated?{truncated:!0}:void 0,message.fullOutputPath),component.setExpanded(this.expanded),this.chat.addChild(component);break}case"custom":{if(!message.display)break;let component=new CustomMessageComponent(message,void 0,this.markdownTheme(),pad);component.setExpanded(this.expanded),this.chat.addChild(component);break}case"compactionSummary":{this.chat.addChild(new Spacer(1));let component=new CompactionSummaryMessageComponent(message,this.markdownTheme(),pad);component.setExpanded(this.expanded),this.chat.addChild(component);break}case"branchSummary":{this.chat.addChild(new Spacer(1));let component=new BranchSummaryMessageComponent(message,this.markdownTheme(),pad);component.setExpanded(this.expanded),this.chat.addChild(component);break}case"user":{let text=typeof message.content=="string"?message.content:message.content.filter(content=>content.type==="text").map(content=>content.text).join("");if(!text)break;this.chat.children.length>0&&this.chat.addChild(new Spacer(1)),this.chat.addChild(new UserMessageComponent(text,this.markdownTheme(),pad));break}case"assistant":this.chat.addChild(this.createAssistantComponent(message));break;default:break}}},AttachConnection=class{options;handlers;reconnectDelayMs;socket;timer;closed=!1;constructor(options,handlers,reconnectDelayMs=RECONNECT_DELAY_MS){this.options=options,this.handlers=handlers,this.reconnectDelayMs=reconnectDelayMs}connect(){if(this.closed)return;let socket=createConnection(this.options.socket);this.socket=socket,socket.setEncoding("utf8");let connected=!1,welcomed=!1,push=createLineReader(MAX_SERVER_LINE_CHARS,line=>{if(this.socket!==socket||!line.trim())return;let message=parseServerMessage(line);if(!message){this.handlers.invalid?.();return}if(message.type==="welcome")welcomed=!0;else if(message.type==="error"&&!welcomed){this.fail(message.message);return}this.handlers.message(message)});socket.on("connect",()=>{connected=!0,this.handlers.connected(!0),this.send({type:"hello",version:CHILD_AGENT_PROTOCOL_VERSION,agentId:this.options.agent})}),socket.on("data",chunk=>{push(chunk)||this.fail("The Raga session sent a message larger than 64 MiB.")}),socket.on("error",error=>{!connected&&!RETRYABLE_CONNECT_ERRORS.has(error.code??"")&&this.fail(`Cannot connect to the subagent socket: ${error.message}`)}),socket.on("close",()=>{this.socket===socket&&(this.socket=void 0,this.handlers.connected(!1),this.closed||(this.timer=setTimeout(()=>this.connect(),this.reconnectDelayMs)))})}send(message){let socket=this.socket;return!socket||socket.destroyed||!socket.writable||socket.connecting?!1:(socket.write(`${JSON.stringify(message)}
|
|
7
|
+
`),!0)}close(){this.closed=!0,this.timer&&clearTimeout(this.timer),this.socket?.destroy(),this.socket=void 0}fail(message){this.closed||(this.close(),this.handlers.failed(message))}};async function runAgentAttach(args){let options;try{options=parseAgentAttachArgs(args)}catch(error){process.stderr.write(`${error instanceof Error?error.message:String(error)}
|
|
8
|
+
${AGENT_ATTACH_USAGE}
|
|
9
|
+
`),process.exitCode=2;return}let settings=SettingsManager.create(process.cwd(),getAgentDir(),{projectTrusted:!1});setCapabilityOverrides(settings.getTerminalCapabilityOverrides()),markTerminalColorsPending(),initTheme(resolveThemeSetting(settings.getThemeSetting(),getTerminalTheme())??SYSTEM_THEME_NAME);let keybindings=KeybindingsManager.create();setKeybindings(keybindings);let ui=createInteractiveTui({tuiMode:"fullscreen",showHardwareCursor:settings.getShowHardwareCursor(),logDirectory:getAgentDir()}),view=new AgentAttachView(ui,{hideThinkingBlock:settings.getHideThinkingBlock(),outputPad:settings.getOutputPad(),showImages:settings.getShowImages(),imageWidthCells:settings.getImageWidthCells(),codeBlockIndent:settings.getCodeBlockIndent(),cwd:process.cwd()}),editor=new CustomEditor(ui,getEditorTheme(),keybindings,{paddingX:settings.getEditorPaddingX(),autocompleteMaxVisible:settings.getAutocompleteMaxVisible()}),viewport=createChatViewport({document:view.chat,pendingMessages:view.pending,status:view.status,editor,footer:view.footer,scrollbar:settings.getFullscreenScrollbar(),scrollbarTrackStyle:text=>theme.fg("scrollbarTrack",text),scrollbarThumbStyle:text=>theme.fg("scrollbarThumb",text)}),root=new VStack([{component:view.header,basis:"auto",grow:0,shrink:0,minSize:1},{component:viewport.root,basis:0,grow:1,shrink:1,minSize:1}]);ui.addChild(root),isViewportTUI(ui)&&ui.setLayoutRoot(root);let connection=new AttachConnection(options,{message:message=>view.apply(message),connected:connected=>view.setConnected(connected),failed:message=>view.setFailed(message),invalid:()=>view.setNotice("Ignored an invalid message from the Raga session.","warning")}),finish=()=>{},finished=new Promise(resolve=>{finish=resolve}),signals=["SIGINT","SIGTERM","SIGHUP"],onSignal=()=>finish();for(let signal of signals)process.on(signal,onSignal);editor.onAction("app.clear",()=>finish()),editor.onCtrlD=()=>finish(),editor.onEscape=()=>{editor.setText(""),ui.requestRender()},editor.onAction("app.tools.expand",()=>view.toggleExpanded()),editor.onSubmit=text=>{if(text.trim()){if(!view.agent?.promptable){editor.setText(text),view.setNotice("read-only: this subagent does not accept messages.","dim");return}if(!connection.send({type:"prompt",text})){editor.setText(text),view.setNotice("Not connected; your message was kept.","warning");return}editor.addToHistory(text),view.setNotice(void 0)}},ui.setFocus(editor),ui.start();try{requestTerminalColors(ui,colors=>{setTerminalColors(colors),setTheme(resolveThemeSetting(settings.getThemeSetting(),getTerminalTheme())??SYSTEM_THEME_NAME),ui.invalidate(),ui.requestRender()}).catch(()=>{}),connection.connect(),ui.requestRender(),await finished}finally{for(let signal of signals)process.off(signal,onSignal);connection.close(),process.stdout.on("error",()=>{});try{ui.stop()}catch{}}}export{AGENT_ATTACH_DISCONNECTED,AGENT_ATTACH_USAGE,AgentAttachView,AttachConnection,MAX_SERVER_LINE_CHARS,createLineReader,formatAttachFooter,formatAttachHeader,parseAgentAttachArgs,parseServerMessage,runAgentAttach,sanitizeTerminalText};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var procEnvCache=null;function getBunSandboxEnvValue(name){if(!(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)){if(procEnvCache===null){procEnvCache=new Map;try{let{readFileSync}=__require("node:fs"),data=readFileSync("/proc/self/environ","utf-8");for(let entry of data.split("\0")){let idx=entry.indexOf("=");idx>0&&procEnvCache.set(entry.slice(0,idx),entry.slice(idx+1))}}catch{}}return procEnvCache.get(name)}}function getProviderEnvValue(name,env){return env?.[name]||(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{createServer}from"node:http";
|
|
2
|
+
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var procEnvCache=null;function getBunSandboxEnvValue(name){if(!(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)){if(procEnvCache===null){procEnvCache=new Map;try{let{readFileSync}=__require("node:fs"),data=readFileSync("/proc/self/environ","utf-8");for(let entry of data.split("\0")){let idx=entry.indexOf("=");idx>0&&procEnvCache.set(entry.slice(0,idx),entry.slice(idx+1))}}catch{}}return procEnvCache.get(name)}}function getProviderEnvValue(name,env){return env?.[name]||(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{createServer}from"node:http";function escapeHtml(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function renderPage(options){let title=escapeHtml(options.title),heading=escapeHtml(options.heading),message=escapeHtml(options.message),details=options.details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="utf-8" />
|
|
@@ -35,12 +35,6 @@ var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(
|
|
|
35
35
|
align-items: center;
|
|
36
36
|
justify-content: center;
|
|
37
37
|
}
|
|
38
|
-
.logo {
|
|
39
|
-
width: 72px;
|
|
40
|
-
height: 72px;
|
|
41
|
-
display: block;
|
|
42
|
-
margin-bottom: 24px;
|
|
43
|
-
}
|
|
44
38
|
h1 {
|
|
45
39
|
margin: 0 0 10px;
|
|
46
40
|
font-size: 28px;
|
|
@@ -66,7 +60,6 @@ var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(
|
|
|
66
60
|
</head>
|
|
67
61
|
<body>
|
|
68
62
|
<main>
|
|
69
|
-
<div class="logo">${LOGO_SVG}</div>
|
|
70
63
|
<h1>${heading}</h1>
|
|
71
64
|
<p>${message}</p>
|
|
72
65
|
${details?`<div class="details">${details}</div>`:""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
+
import{mcpNamespace,validateMcpServerConfig}from"./chunk-P2EB6CEF.js";import{require_proper_lockfile}from"./chunk-K22YTJFL.js";import{PROJECT_CONFIG_DIR_NAME,canonicalizePath,resolvePath,stripBom}from"./chunk-SK25JXS4.js";import{__toESM}from"./chunk-JXWJOIH4.js";var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{existsSync,mkdirSync,readFileSync,writeFileSync}from"node:fs";import{homedir}from"node:os";import{dirname,join}from"node:path";var TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES=["settings.json","mcp.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"];function normalizeCwd(cwd){return canonicalizePath(resolvePath(cwd))}function findNearestTrustEntry(data,cwd){let currentDir=normalizeCwd(cwd);for(;;){let value=data[currentDir];if(value===!0||value===!1)return{path:currentDir,decision:value};let parentDir=dirname(currentDir);if(parentDir===currentDir)return null;currentDir=parentDir}}function getProjectTrustParentPath(cwd){let trustPath=normalizeCwd(cwd),parentDir=dirname(trustPath);return parentDir===trustPath?void 0:parentDir}function getProjectTrustOptions(cwd,options){let trustPath=normalizeCwd(cwd),trustOptions=[{label:"Trust",trusted:!0,updates:[{path:trustPath,decision:!0}],savedPath:trustPath}],parentPath=getProjectTrustParentPath(cwd);return parentPath!==void 0&&trustOptions.push({label:`Trust parent folder (${parentPath})`,trusted:!0,updates:[{path:parentPath,decision:!0},{path:trustPath,decision:null}],savedPath:parentPath}),options?.includeSessionOnly&&trustOptions.push({label:"Trust (this session only)",trusted:!0,updates:[]}),trustOptions.push({label:"Do not trust",trusted:!1,updates:[{path:trustPath,decision:!1}],savedPath:trustPath}),options?.includeSessionOnly&&trustOptions.push({label:"Do not trust (this session only)",trusted:!1,updates:[]}),trustOptions}function readTrustFile(path){if(!existsSync(path))return{};let parsed;try{parsed=JSON.parse(stripBom(readFileSync(path,"utf-8")))}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Failed to read trust store ${path}: ${message}`)}if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))throw new Error(`Invalid trust store ${path}: expected an object`);let data={};for(let[key,value]of Object.entries(parsed)){if(value!==!0&&value!==!1&&value!==null)throw new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);data[key]=value}return data}function writeTrustFile(path,data){let sorted={};for(let key of Object.keys(data).sort()){let value=data[key];(value===!0||value===!1||value===null)&&(sorted[key]=value)}mkdirSync(dirname(path),{recursive:!0}),writeFileSync(path,`${JSON.stringify(sorted,null,2)}
|
|
3
|
+
`,"utf-8")}function acquireTrustLockSync(path){let trustDir=dirname(path);mkdirSync(trustDir,{recursive:!0});let maxAttempts=10,delayMs=20,lastError;for(let attempt=1;attempt<=maxAttempts;attempt++)try{return import_proper_lockfile.default.lockSync(trustDir,{realpath:!1,lockfilePath:`${path}.lock`})}catch(error){if((typeof error=="object"&&error!==null&&"code"in error?String(error.code):void 0)!=="ELOCKED"||attempt===maxAttempts)throw error;lastError=error;let start=Date.now();for(;Date.now()-start<delayMs;);}throw lastError instanceof Error?lastError:new Error("Failed to acquire trust store lock")}function withTrustFileLock(path,fn){let release=acquireTrustLockSync(path);try{return fn()}finally{release()}}function hasTrustRequiringProjectResources(cwd){let homeDir=canonicalizePath(resolvePath(process.env.HOME||homedir())),userAgentsSkillsDir=join(homeDir,".agents","skills"),currentDir=canonicalizePath(resolvePath(cwd)),configDir=join(currentDir,PROJECT_CONFIG_DIR_NAME);if(TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some(entry=>existsSync(join(configDir,entry))))return!0;for(;;){let agentsSkillsDir=join(currentDir,".agents","skills");if(agentsSkillsDir!==userAgentsSkillsDir&&existsSync(agentsSkillsDir))return!0;let parentDir=dirname(currentDir);if(parentDir===currentDir)return!1;currentDir=parentDir}}var ProjectTrustStore=class{trustPath;constructor(agentDir){this.trustPath=join(resolvePath(agentDir),"trust.json")}get(cwd){return this.getEntry(cwd)?.decision??null}getEntry(cwd){return withTrustFileLock(this.trustPath,()=>{let data=readTrustFile(this.trustPath);return findNearestTrustEntry(data,cwd)})}set(cwd,decision){this.setMany([{path:cwd,decision}])}setMany(decisions){withTrustFileLock(this.trustPath,()=>{let data=readTrustFile(this.trustPath);for(let{path,decision}of decisions){let key=normalizeCwd(path);decision===null?delete data[key]:data[key]=decision}writeTrustFile(this.trustPath,data)})}};import{existsSync as existsSync2,mkdirSync as mkdirSync2,readFileSync as readFileSync2,writeFileSync as writeFileSync2}from"node:fs";import{dirname as dirname2,join as join2}from"node:path";var OVERRIDE_KEYS=["enabled","exposure","toolExposure"];function isOverride(value){return value.command===void 0&&value.url===void 0&&value.type===void 0}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function readConfigFile(path,scope,state){let{servers,errors}=state;if(!existsSync2(path))return;let parsed;try{parsed=JSON.parse(stripBom(readFileSync2(path,"utf8")))}catch(error){errors.push(`${path}: ${error instanceof Error?error.message:String(error)}`);return}if(!isRecord(parsed)||parsed.mcpServers!==void 0&&!isRecord(parsed.mcpServers)){errors.push(`${path}: expected an object with an "mcpServers" object`);return}typeof parsed.autoEnableCodemode=="boolean"?state.autoEnableCodemode=parsed.autoEnableCodemode:parsed.autoEnableCodemode!==void 0&&errors.push(`${path}: autoEnableCodemode must be a boolean`);for(let[name,value]of Object.entries(parsed.mcpServers??{})){if(scope==="project"&&isRecord(value)&&isOverride(value)){let base=servers.get(name),extra=Object.keys(value).filter(key=>!OVERRIDE_KEYS.includes(key));if(!base)errors.push(`${path}: server "${name}" needs "command" or "url", or a global server to override`);else if(extra.length>0)errors.push(`${path}: server "${name}": an override can only set ${OVERRIDE_KEYS.join(", ")}`);else{let config2=validateMcpServerConfig(name,{...base.config,...value});typeof config2=="string"?errors.push(`${path}: ${config2}`):servers.set(name,{...base,config:config2,override:path})}continue}let config=validateMcpServerConfig(name,value);if(typeof config=="string"){errors.push(`${path}: ${config}`);continue}let clash=[...servers.keys()].find(other=>other!==name&&mcpNamespace(other)===mcpNamespace(name));if(clash){errors.push(`${path}: server "${name}" conflicts with "${clash}"`);continue}if(scope==="project"&&"url"in config&&config.auth){errors.push(`${path}: server "${name}": auth is only allowed in the global mcp.json`);continue}servers.set(name,{name,config,source:path,scope})}}function loadMcpConfig(options){let state={servers:new Map,errors:[]};readConfigFile(join2(options.agentDir,"mcp.json"),"global",state);let projectConfig=options.projectTrusted?join2(options.cwd,PROJECT_CONFIG_DIR_NAME,"mcp.json"):void 0;return projectConfig&&readConfigFile(projectConfig,"project",state),{servers:[...state.servers.values()],...state.autoEnableCodemode===void 0?{}:{autoEnableCodemode:state.autoEnableCodemode},errors:state.errors,...projectConfig?{projectConfig}:{}}}function updateMcpServerConfig(path,name,patch,options={}){editMcpServers(path,(servers,parsed)=>{let server=servers?.[name];if(server===void 0&&options.override&&(server={},parsed.mcpServers={...servers,[name]:server}),!isRecord(server))throw new Error(`${path} does not define MCP server "${name}"`);let keepDefaults=isOverride(server);return patch.enabled!==void 0&&(patch.enabled&&!keepDefaults?delete server.enabled:server.enabled=patch.enabled),patch.exposure!==void 0&&(patch.exposure==="codemode"&&!keepDefaults?delete server.exposure:server.exposure=patch.exposure),!0})}function addMcpServerConfig(path,name,config){let replaced=!1;return editMcpServers(path,(servers,parsed)=>{let target=servers??{};return replaced=target[name]!==void 0,target[name]=config,parsed.mcpServers=target,!0}),replaced}function removeMcpServerConfig(path,name){if(!existsSync2(path))return!1;let removed=!1;return editMcpServers(path,servers=>!servers||servers[name]===void 0?!1:(delete servers[name],removed=!0,!0)),removed}function editMcpServers(path,edit){let text=existsSync2(path)?stripBom(readFileSync2(path,"utf8")):void 0,parsed=text===void 0?{}:JSON.parse(text);if(!isRecord(parsed)||parsed.mcpServers!==void 0&&!isRecord(parsed.mcpServers))throw new Error(`${path}: expected an object with an "mcpServers" object`);let servers=isRecord(parsed.mcpServers)?parsed.mcpServers:void 0;if(!edit(servers,parsed))return;let indent=text&&/^([ \t]+)\S/m.exec(text)?.[1]||" ";mkdirSync2(dirname2(path),{recursive:!0}),writeFileSync2(path,`${JSON.stringify(parsed,null,indent)}
|
|
4
|
+
`)}export{getProjectTrustOptions,hasTrustRequiringProjectResources,ProjectTrustStore,loadMcpConfig,updateMcpServerConfig,addMcpServerConfig,removeMcpServerConfig};
|