cli-link 0.0.1

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.
Files changed (34) hide show
  1. package/README.md +271 -0
  2. package/bin/agentpilot.js +239 -0
  3. package/dist/client/assets/History-DR_K6WbO.js +3 -0
  4. package/dist/client/assets/MarkdownRenderer-D9IwexPM.js +1 -0
  5. package/dist/client/assets/PageTopBar-SnTIrSb5.js +1 -0
  6. package/dist/client/assets/Session-EFYFIC_X.js +11 -0
  7. package/dist/client/assets/Settings-DgmHC_Hw.js +1 -0
  8. package/dist/client/assets/Workspace-CJvVQVzU.js +8 -0
  9. package/dist/client/assets/WorkspaceLinkedText-D6hNg0T9.js +2 -0
  10. package/dist/client/assets/code-highlight-CEcsuMpw.js +1 -0
  11. package/dist/client/assets/index-Bk4_acsd.css +1 -0
  12. package/dist/client/assets/index-C89UCwGk.js +2 -0
  13. package/dist/client/assets/vendor-icons-S_ObYVVf.js +331 -0
  14. package/dist/client/assets/vendor-markdown-BDwu-Ux6.js +35 -0
  15. package/dist/client/assets/vendor-motion-n6Lx6G4a.js +9 -0
  16. package/dist/client/assets/vendor-react-DSV5aFEg.js +67 -0
  17. package/dist/client/assets/vendor-virtual-CcftJrIC.js +4 -0
  18. package/dist/client/favicon.svg +18 -0
  19. package/dist/client/icons/apple-touch-icon.png +0 -0
  20. package/dist/client/icons/icon-192.png +0 -0
  21. package/dist/client/icons/icon-512.png +0 -0
  22. package/dist/client/index.html +34 -0
  23. package/dist/client/manifest.webmanifest +59 -0
  24. package/dist/client/sw.js +143 -0
  25. package/dist/client//344/273/243/347/240/201/351/241/265/351/235/242.png +0 -0
  26. package/dist/client//345/216/206/345/217/262/350/256/260/345/275/225.png +0 -0
  27. package/dist/client//345/257/271/350/257/235/351/241/265/351/235/242.png +0 -0
  28. package/dist/client//350/256/276/347/275/256/351/241/265/351/235/242.png +0 -0
  29. package/dist/server/cli-manager.js +1532 -0
  30. package/dist/server/codex-history.js +280 -0
  31. package/dist/server/index.js +2097 -0
  32. package/dist/server/store.js +594 -0
  33. package/dist/server/terminal-qr.js +317 -0
  34. package/package.json +71 -0
@@ -0,0 +1,59 @@
1
+ {
2
+ "id": "/",
3
+ "name": "AgentPilot - AI Agent Remote",
4
+ "short_name": "AgentPilot",
5
+ "description": "A mobile-first remote console for Claude Code CLI and Codex CLI.",
6
+ "lang": "zh-CN",
7
+ "start_url": "/session",
8
+ "scope": "/",
9
+ "display": "standalone",
10
+ "orientation": "portrait",
11
+ "theme_color": "#7c3aed",
12
+ "background_color": "#030712",
13
+ "icons": [
14
+ {
15
+ "src": "/favicon.svg",
16
+ "sizes": "any",
17
+ "type": "image/svg+xml",
18
+ "purpose": "any"
19
+ },
20
+ {
21
+ "src": "/icons/icon-192.png",
22
+ "sizes": "192x192",
23
+ "type": "image/png",
24
+ "purpose": "any"
25
+ },
26
+ {
27
+ "src": "/icons/icon-512.png",
28
+ "sizes": "512x512",
29
+ "type": "image/png",
30
+ "purpose": "any"
31
+ }
32
+ ],
33
+ "shortcuts": [
34
+ {
35
+ "name": "对话",
36
+ "short_name": "对话",
37
+ "url": "/session",
38
+ "icons": [{ "src": "/icons/icon-192.png", "sizes": "192x192" }]
39
+ },
40
+ {
41
+ "name": "代码",
42
+ "short_name": "代码",
43
+ "url": "/workspace",
44
+ "icons": [{ "src": "/icons/icon-192.png", "sizes": "192x192" }]
45
+ },
46
+ {
47
+ "name": "记录",
48
+ "short_name": "记录",
49
+ "url": "/history",
50
+ "icons": [{ "src": "/icons/icon-192.png", "sizes": "192x192" }]
51
+ },
52
+ {
53
+ "name": "设置",
54
+ "short_name": "设置",
55
+ "url": "/settings",
56
+ "icons": [{ "src": "/icons/icon-192.png", "sizes": "192x192" }]
57
+ }
58
+ ]
59
+ }
@@ -0,0 +1,143 @@
1
+ const CACHE_VERSION = 'agentpilot-shell-v1';
2
+ const SHELL_CACHE = `${CACHE_VERSION}:shell`;
3
+
4
+ const APP_SHELL_URLS = [
5
+ '/',
6
+ '/index.html',
7
+ '/manifest.webmanifest',
8
+ '/favicon.svg',
9
+ '/icons/icon-192.png',
10
+ '/icons/icon-512.png',
11
+ '/icons/apple-touch-icon.png',
12
+ ];
13
+
14
+ const STATIC_ASSET_PATTERN = /\.(?:css|js|mjs|svg|png|jpg|jpeg|webp|ico|woff|woff2)$/;
15
+
16
+ function isApiUrl(url) {
17
+ return url.pathname.startsWith('/api/');
18
+ }
19
+
20
+ function isCacheableShellUrl(url) {
21
+ if (url.pathname === '/sw.js') return false;
22
+ if (isApiUrl(url)) return false;
23
+ return (
24
+ url.pathname.startsWith('/assets/') ||
25
+ url.pathname.startsWith('/icons/') ||
26
+ url.pathname === '/favicon.svg' ||
27
+ url.pathname === '/manifest.webmanifest' ||
28
+ STATIC_ASSET_PATTERN.test(url.pathname)
29
+ );
30
+ }
31
+
32
+ async function cacheUrl(cache, url) {
33
+ try {
34
+ const response = await fetch(url, { cache: 'no-store' });
35
+ if (response.ok) {
36
+ await cache.put(url, response);
37
+ }
38
+ } catch {
39
+ // Best-effort cache warmup. Runtime caching still covers successful loads.
40
+ }
41
+ }
42
+
43
+ function discoverShellAssets(html) {
44
+ const urls = new Set();
45
+ const attrPattern = /\b(?:href|src)="([^"]+)"/g;
46
+ let match;
47
+ while ((match = attrPattern.exec(html)) !== null) {
48
+ try {
49
+ const url = new URL(match[1], self.location.origin);
50
+ if (url.origin === self.location.origin && isCacheableShellUrl(url)) {
51
+ urls.add(url.href);
52
+ }
53
+ } catch {
54
+ // Ignore malformed values.
55
+ }
56
+ }
57
+ return urls;
58
+ }
59
+
60
+ async function warmAppShellCache() {
61
+ const cache = await caches.open(SHELL_CACHE);
62
+ await Promise.all(APP_SHELL_URLS.map((url) => cacheUrl(cache, url)));
63
+
64
+ try {
65
+ const indexResponse = await fetch('/index.html', { cache: 'no-store' });
66
+ if (!indexResponse.ok) return;
67
+
68
+ const html = await indexResponse.clone().text();
69
+ await cache.put('/index.html', indexResponse.clone());
70
+ await cache.put('/', indexResponse.clone());
71
+
72
+ const discoveredUrls = discoverShellAssets(html);
73
+ await Promise.all(Array.from(discoveredUrls).map((url) => cacheUrl(cache, url)));
74
+ } catch {
75
+ // Keep the existing shell cache if the network is unavailable.
76
+ }
77
+ }
78
+
79
+ async function networkFirstNavigation(request) {
80
+ const cache = await caches.open(SHELL_CACHE);
81
+ try {
82
+ const response = await fetch(request);
83
+ if (response.ok) {
84
+ await cache.put(request, response.clone());
85
+ }
86
+ return response;
87
+ } catch {
88
+ return (await cache.match('/index.html')) || (await cache.match('/')) || Response.error();
89
+ }
90
+ }
91
+
92
+ async function staleWhileRevalidate(request) {
93
+ const cache = await caches.open(SHELL_CACHE);
94
+ const cached = await cache.match(request);
95
+ const fetched = fetch(request)
96
+ .then((response) => {
97
+ if (response.ok) {
98
+ cache.put(request, response.clone()).catch(() => {});
99
+ }
100
+ return response;
101
+ })
102
+ .catch(() => undefined);
103
+
104
+ if (cached) return cached;
105
+ return (await fetched) || Response.error();
106
+ }
107
+
108
+ self.addEventListener('install', (event) => {
109
+ event.waitUntil(warmAppShellCache());
110
+ });
111
+
112
+ self.addEventListener('activate', (event) => {
113
+ event.waitUntil(
114
+ caches
115
+ .keys()
116
+ .then((keys) => Promise.all(keys.filter((key) => !key.startsWith(CACHE_VERSION)).map((key) => caches.delete(key))))
117
+ .then(() => self.clients.claim())
118
+ );
119
+ });
120
+
121
+ self.addEventListener('message', (event) => {
122
+ if (event.data && event.data.type === 'SKIP_WAITING') {
123
+ self.skipWaiting();
124
+ }
125
+ });
126
+
127
+ self.addEventListener('fetch', (event) => {
128
+ const { request } = event;
129
+ if (request.method !== 'GET') return;
130
+
131
+ const url = new URL(request.url);
132
+ if (url.origin !== self.location.origin) return;
133
+ if (isApiUrl(url)) return;
134
+
135
+ if (request.mode === 'navigate') {
136
+ event.respondWith(networkFirstNavigation(request));
137
+ return;
138
+ }
139
+
140
+ if (isCacheableShellUrl(url)) {
141
+ event.respondWith(staleWhileRevalidate(request));
142
+ }
143
+ });