aegiscode 7.0.13 → 7.0.15

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 (109) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +3 -2
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2932
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3008
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -3987
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/fingerprint.js +1 -592
  28. package/src/format.js +1 -259
  29. package/src/fuzzy.js +1 -119
  30. package/src/history.js +1 -401
  31. package/src/init.js +1 -175
  32. package/src/input.js +1 -139
  33. package/src/keys.js +1 -183
  34. package/src/markdown.js +1 -306
  35. package/src/models.js +1 -487
  36. package/src/naming.js +1 -229
  37. package/src/overlays.js +1 -461
  38. package/src/panels.js +1 -1418
  39. package/src/ping.js +1 -226
  40. package/src/presence.js +1 -238
  41. package/src/render.js +1 -515
  42. package/src/screen.js +1 -518
  43. package/src/screens.js +1 -896
  44. package/src/secret.js +1 -59
  45. package/src/securefs.js +1 -359
  46. package/src/settings.js +1 -155
  47. package/src/shared.js +1 -52
  48. package/src/sharedpaths.js +1 -53
  49. package/src/signup.js +1 -156
  50. package/src/summarize.js +1 -95
  51. package/src/sysdiag.js +1 -585
  52. package/src/system.js +1 -40
  53. package/src/theme.js +1 -570
  54. package/src/title.js +1 -220
  55. package/src/todos.js +1 -115
  56. package/src/tokens.js +1 -263
  57. package/src/topup.js +1 -210
  58. package/src/update.js +1 -181
  59. package/vendor/client/aegis.js +1 -2054
  60. package/vendor/client/attest.js +1 -442
  61. package/vendor/client/authorship-key.js +1 -410
  62. package/vendor/client/auto-provision.js +1 -134
  63. package/vendor/client/brain-catalog.js +1 -268
  64. package/vendor/client/byok-catalog.js +1 -230
  65. package/vendor/client/credentials.js +1 -494
  66. package/vendor/client/device-fingerprint.js +1 -141
  67. package/vendor/client/drive-connect.js +1 -85
  68. package/vendor/client/drive-upload.js +1 -174
  69. package/vendor/client/env-file.js +1 -1273
  70. package/vendor/client/fingerprint.js +1 -1064
  71. package/vendor/client/foreign-memory.js +1 -669
  72. package/vendor/client/google-signin.js +1 -125
  73. package/vendor/client/hooks.js +1 -430
  74. package/vendor/client/model-discovery.js +1 -330
  75. package/vendor/client/platform.js +1 -937
  76. package/vendor/client/prefs.js +1 -351
  77. package/vendor/client/presence-constants.js +1 -107
  78. package/vendor/client/presence.js +1 -438
  79. package/vendor/client/record-vault.js +3 -1055
  80. package/vendor/client/session-store.js +1 -548
  81. package/vendor/client/topup.js +1 -297
  82. package/vendor/client/touch.js +1 -458
  83. package/vendor/client/update.js +1 -704
  84. package/vendor/client/user-models.js +1 -381
  85. package/vendor/desktop/lib/local/agents.js +1 -105
  86. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  87. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  88. package/vendor/desktop/lib/local/context.js +1 -95
  89. package/vendor/desktop/lib/local/engine.js +1 -3228
  90. package/vendor/desktop/lib/local/entitlement.js +1 -654
  91. package/vendor/desktop/lib/local/git-scope.js +1 -228
  92. package/vendor/desktop/lib/local/local.js +1 -2135
  93. package/vendor/desktop/lib/local/prompt.js +1 -275
  94. package/vendor/desktop/lib/local/queue.js +1 -560
  95. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  96. package/vendor/desktop/lib/local/shell.js +1 -680
  97. package/vendor/desktop/lib/local/tools.js +1 -1238
  98. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  99. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  100. package/vendor/desktop/lib/settings.js +1 -890
  101. package/vendor/desktop/renderer/usage.js +1 -1239
  102. package/vendor/hosts/install.js +1 -638
  103. package/vendor/hosts/openai-shim.js +1 -515
  104. package/vendor/hosts/spec.js +1 -164
  105. package/vendor/hosts/targets.js +1 -346
  106. package/vendor/mcp/server.js +1 -221
  107. package/vendor/mcp/tools.js +1 -408
  108. package/vendor/one/src/child.js +1 -285
  109. package/vendor/one/src/permissions.js +1 -369
@@ -1,87 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * drive-connect.js — the desktop half of aegis1's Google Drive OAuth.
10
- *
11
- * aegis1 already runs the full web side of this: `/connect/drive` sends the
12
- * browser through Google's consent screen with the `drive.file` scope, saves
13
- * the resulting tokens on whichever account that Google identity resolves
14
- * to, and lands on a static "connected" page. `/api/drive/token` then hands
15
- * back a fresh (server-refreshed) access token for that account, authenticated
16
- * with the ordinary AEGIS API key — see `client/aegis.js`'s `driveToken()`.
17
- *
18
- * Unlike `/auth/google` (see `client/google-signin.js`), `/connect/drive` has
19
- * no desktop round-trip: it never redirects back to a local callback, so
20
- * there is nothing here to listen for. This module does the other honest
21
- * thing instead — open the browser to it, and POLL the status endpoint
22
- * (this machine's own API key) until the account shows connected, or give up
23
- * after a timeout. The caller provides the actual browser-opening (Electron's
24
- * `shell.openExternal`); this module is Electron-free so it can be driven by
25
- * a test with a stub `aegis` client and no network.
26
- *
27
- * ONE PRECONDITION THIS MODULE DOES NOT ENFORCE, BECAUSE IT CANNOT:
28
- * `/connect/drive` resolves the account by Google identity (google_id, then
29
- * email), not by whatever account this machine's API key already belongs to.
30
- * So polling only ever reports connected when THIS machine is already signed
31
- * in with that same Google identity — otherwise the browser attaches the
32
- * Drive tokens to a different account than the one being polled, and the
33
- * poll simply times out. `desktop/lib/google-connect.js` is what sequences
34
- * "sign in with Google first" ahead of this.
35
- */
36
-
37
- /** `${apiBase}/connect/drive` — the one URL this flow opens. */
38
- function driveConnectUrl(apiBase) {
39
- return `${String(apiBase || '').replace(/\/+$/, '')}/connect/drive`;
40
- }
41
-
42
- /**
43
- * One status check: is a Drive token on file for this account?
44
- *
45
- * @param {{driveToken: () => Promise<{connected:boolean, email?:string}>}} aegis
46
- */
47
- async function driveStatus(aegis) {
48
- const data = await aegis.driveToken();
49
- return {
50
- connected: Boolean(data && data.connected),
51
- email: (data && data.email) || null,
52
- };
53
- }
54
-
55
- /**
56
- * Poll `driveStatus` until it reports connected, or time out.
57
- *
58
- * The browser round-trip has no signal of its own to wait on (unlike
59
- * `startGoogleSignIn`'s local callback server), so this is the only way the
60
- * caller learns the user actually finished the consent screen — or gave up
61
- * on it, which is why this is bounded rather than polled forever.
62
- *
63
- * @param {object} aegis a client exposing `driveToken()`
64
- * @param {{timeoutMs?:number, pollMs?:number, signal?:AbortSignal}} [opts]
65
- */
66
- async function waitForDriveConnected(aegis, opts = {}) {
67
- const timeoutMs = Number(opts.timeoutMs) > 0 ? Number(opts.timeoutMs) : 3 * 60 * 1000;
68
- const pollMs = Number(opts.pollMs) > 0 ? Number(opts.pollMs) : 2000;
69
- const signal = opts.signal || null;
70
- const deadline = Date.now() + timeoutMs;
71
-
72
- for (;;) {
73
- const status = await driveStatus(aegis);
74
- if (status.connected) return status;
75
- if (signal && signal.aborted) {
76
- const e = new Error('cancelled');
77
- e.name = 'AbortError';
78
- throw e;
79
- }
80
- if (Date.now() >= deadline) {
81
- throw new Error(`timed out after ${Math.round(timeoutMs / 1000)}s waiting for Google Drive to connect`);
82
- }
83
- await new Promise((resolve) => setTimeout(resolve, pollMs));
84
- }
85
- }
86
-
87
- module.exports = { driveConnectUrl, driveStatus, waitForDriveConnected };
3
+ "use strict";function driveConnectUrl(e){return`${String(e||"").replace(/\/+$/,"")}/connect/drive`}async function driveStatus(e){const n=await e.driveToken(),o=Boolean(n&&n.connected),t=n&&n.google_linked;return{connected:o,googleLinked:o||!0===t,googleLinkedKnown:"boolean"==typeof t||o,email:n&&n.email||null}}async function waitForDriveConnected(e,n={}){const o=Number(n.timeoutMs)>0?Number(n.timeoutMs):18e4,t=Number(n.pollMs)>0?Number(n.pollMs):2e3,r=n.signal||null,i=Date.now()+o;for(;;){const n=await driveStatus(e);if(n.connected)return n;if(r&&r.aborted){const e=new Error("cancelled");throw e.name="AbortError",e}if(Date.now()>=i)throw new Error(`timed out after ${Math.round(o/1e3)}s waiting for Google Drive to connect`);await new Promise((e=>setTimeout(e,t)))}}module.exports={driveConnectUrl:driveConnectUrl,driveStatus:driveStatus,waitForDriveConnected:waitForDriveConnected};
@@ -1,176 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * drive-upload.js — a Drive v3 REST client, scoped to exactly one job:
10
- * keep a single memory-backup file, in a single app folder, up to date.
11
- *
12
- * This talks to Google's API directly with the access token
13
- * `client/drive-connect.js` obtains (via `/api/drive/token`) — it never goes
14
- * through aegis1, and aegis1 never sees the memory content this uploads.
15
- *
16
- * Scoped to `drive.file` (the scope `/connect/drive` requests): that grant
17
- * only ever sees files this app itself creates, which is why every write
18
- * here goes through `findOrCreateFolder`/`findFileInFolder` rather than
19
- * assuming some well-known id — there is no well-known id this scope could
20
- * resolve, and a file this app did not create is invisible to it even by
21
- * name. One stable file is overwritten in place on every sync rather than
22
- * creating a new one each time, so a daily backup habit does not pile up a
23
- * thousand same-named files with no way to tell them apart.
24
- */
25
-
26
- const DRIVE_FILES_URL = 'https://www.googleapis.com/drive/v3/files';
27
- const DRIVE_UPLOAD_URL = 'https://www.googleapis.com/upload/drive/v3/files';
28
- const FOLDER_MIME = 'application/vnd.google-apps.folder';
29
- const BOUNDARY = 'aegiscode-drive-upload-boundary';
30
-
31
- const DEFAULT_FOLDER = 'AEGIS Memory';
32
- const DEFAULT_FILE = 'aegis-memory-backup.json';
33
-
34
- function resolveFetch(fetchImpl) {
35
- const f = fetchImpl || (typeof fetch === 'function' ? fetch : null);
36
- if (!f) throw new Error('drive: this Node has no global fetch — upgrade to Node 22+');
37
- return f;
38
- }
39
-
40
- /** Escape a value for Drive's `q=` string-literal quoting rules. */
41
- function escapeQ(value) {
42
- return String(value).replace(/\\/g, '\\\\').replace(/'/g, "\\'");
43
- }
44
-
45
- async function driveRequest(fetchImpl, url, { method = 'GET', accessToken, body, headers } = {}) {
46
- const f = resolveFetch(fetchImpl);
47
- const res = await f(url, {
48
- method,
49
- headers: { Authorization: `Bearer ${accessToken}`, ...(headers || {}) },
50
- body,
51
- });
52
- const text = await res.text();
53
- let data = null;
54
- try {
55
- data = text ? JSON.parse(text) : null;
56
- } catch {
57
- data = null;
58
- }
59
- if (!res.ok) {
60
- const rawMsg = (data && data.error && (data.error.message || data.error)) || text.slice(0, 200) || `HTTP ${res.status}`;
61
- const err = new Error(`drive: ${method} ${url.split('?')[0]} failed — ${typeof rawMsg === 'string' ? rawMsg : JSON.stringify(rawMsg)}`);
62
- err.status = res.status;
63
- err.data = data;
64
- throw err;
65
- }
66
- return data || {};
67
- }
68
-
69
- /** The first file matching an exact query, or null. */
70
- async function findOne(fetchImpl, accessToken, query) {
71
- const url = `${DRIVE_FILES_URL}?q=${encodeURIComponent(query)}&fields=${encodeURIComponent('files(id,name)')}&pageSize=1`;
72
- const data = await driveRequest(fetchImpl, url, { accessToken });
73
- const files = Array.isArray(data.files) ? data.files : [];
74
- return files[0] || null;
75
- }
76
-
77
- /** This app's folder by name, creating it the first time. Returns its id. */
78
- async function findOrCreateFolder(accessToken, name, { fetchImpl } = {}) {
79
- const query = `mimeType='${FOLDER_MIME}' and name='${escapeQ(name)}' and trashed=false`;
80
- const existing = await findOne(fetchImpl, accessToken, query);
81
- if (existing) return existing.id;
82
- const created = await driveRequest(fetchImpl, DRIVE_FILES_URL, {
83
- method: 'POST',
84
- accessToken,
85
- headers: { 'Content-Type': 'application/json' },
86
- body: JSON.stringify({ name, mimeType: FOLDER_MIME }),
87
- });
88
- return created.id;
89
- }
90
-
91
- /** One file by name inside a given folder, or null. */
92
- async function findFileInFolder(accessToken, name, folderId, { fetchImpl } = {}) {
93
- const query = `'${escapeQ(folderId)}' in parents and name='${escapeQ(name)}' and trashed=false`;
94
- return findOne(fetchImpl, accessToken, query);
95
- }
96
-
97
- /**
98
- * Create a new file: a multipart/related body (metadata part naming the
99
- * parent folder, content part carrying the bytes) — the shape Drive's
100
- * `uploadType=multipart` requires for a create, since a plain media upload
101
- * has nowhere to say which folder the file belongs in.
102
- */
103
- async function createFile(accessToken, { name, folderId, content, mimeType }, { fetchImpl } = {}) {
104
- const metadata = JSON.stringify({ name, parents: [folderId] });
105
- const body =
106
- `--${BOUNDARY}\r\n` +
107
- `Content-Type: application/json; charset=UTF-8\r\n\r\n${metadata}\r\n` +
108
- `--${BOUNDARY}\r\n` +
109
- `Content-Type: ${mimeType}\r\n\r\n${content}\r\n` +
110
- `--${BOUNDARY}--`;
111
- return driveRequest(
112
- fetchImpl,
113
- `${DRIVE_UPLOAD_URL}?uploadType=multipart&fields=${encodeURIComponent('id,webViewLink')}`,
114
- {
115
- method: 'POST',
116
- accessToken,
117
- headers: { 'Content-Type': `multipart/related; boundary=${BOUNDARY}` },
118
- body,
119
- }
120
- );
121
- }
122
-
123
- /**
124
- * Overwrite an existing file's content in place. A plain media upload is
125
- * enough here — the name and parent folder never change on a resync, so
126
- * there is nothing a metadata part would need to say.
127
- */
128
- async function updateFileContent(accessToken, fileId, content, mimeType, { fetchImpl } = {}) {
129
- return driveRequest(
130
- fetchImpl,
131
- `${DRIVE_UPLOAD_URL}/${encodeURIComponent(fileId)}?uploadType=media&fields=${encodeURIComponent('id,webViewLink')}`,
132
- {
133
- method: 'PATCH',
134
- accessToken,
135
- headers: { 'Content-Type': mimeType },
136
- body: content,
137
- }
138
- );
139
- }
140
-
141
- /**
142
- * Upload (create or overwrite) one memory backup file in the user's Drive.
143
- *
144
- * @param {string} accessToken a live Drive access token (client/drive-connect.js / aegis.driveToken())
145
- * @param {string} content the file's bytes — the caller serialises; this module never shapes the memory export itself
146
- * @param {{folderName?:string, fileName?:string, mimeType?:string, fetchImpl?:Function}} [opts]
147
- * @returns {Promise<{fileId:string, webViewLink:string|null, updated:boolean}>}
148
- */
149
- async function uploadMemoryBackup(accessToken, content, opts = {}) {
150
- const folderName = opts.folderName || DEFAULT_FOLDER;
151
- const fileName = opts.fileName || DEFAULT_FILE;
152
- const mimeType = opts.mimeType || 'application/json';
153
- const fetchImpl = opts.fetchImpl;
154
-
155
- const folderId = await findOrCreateFolder(accessToken, folderName, { fetchImpl });
156
- const existing = await findFileInFolder(accessToken, fileName, folderId, { fetchImpl });
157
- const result = existing
158
- ? await updateFileContent(accessToken, existing.id, content, mimeType, { fetchImpl })
159
- : await createFile(accessToken, { name: fileName, folderId, content, mimeType }, { fetchImpl });
160
-
161
- return {
162
- fileId: result.id || (existing && existing.id) || null,
163
- webViewLink: result.webViewLink || null,
164
- updated: Boolean(existing),
165
- };
166
- }
167
-
168
- module.exports = {
169
- DEFAULT_FOLDER,
170
- DEFAULT_FILE,
171
- findOrCreateFolder,
172
- findFileInFolder,
173
- createFile,
174
- updateFileContent,
175
- uploadMemoryBackup,
176
- };
3
+ const e="https://www.googleapis.com/drive/v3/files",n="https://www.googleapis.com/upload/drive/v3/files",t="application/vnd.google-apps.folder",o="aegiscode-drive-upload-boundary",a="AEGIS Memory",i="aegis-memory-backup.json";function r(e){return String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")}async function s(e,n,{method:t="GET",accessToken:o,body:a,headers:i}={}){const r=function(e){const n=e||("function"==typeof fetch?fetch:null);if(!n)throw new Error("drive: this Node has no global fetch — upgrade to Node 22+");return n}(e),s=await r(n,{method:t,headers:{Authorization:`Bearer ${o}`,...i||{}},body:a}),d=await s.text();let c=null;try{c=d?JSON.parse(d):null}catch{c=null}if(!s.ok){const e=c&&c.error&&(c.error.message||c.error)||d.slice(0,200)||`HTTP ${s.status}`,o=new Error(`drive: ${t} ${n.split("?")[0]} failed — ${"string"==typeof e?e:JSON.stringify(e)}`);throw o.status=s.status,o.data=c,o}return c||{}}async function d(n,t,o){const a=`${e}?q=${encodeURIComponent(o)}&fields=${encodeURIComponent("files(id,name)")}&pageSize=1`,i=await s(n,a,{accessToken:t});return(Array.isArray(i.files)?i.files:[])[0]||null}async function c(n,o,{fetchImpl:a}={}){const i=`mimeType='${t}' and name='${r(o)}' and trashed=false`,c=await d(a,n,i);return c?c.id:(await s(a,e,{method:"POST",accessToken:n,headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o,mimeType:t})})).id}async function l(e,n,t,{fetchImpl:o}={}){return d(o,e,`'${r(t)}' in parents and name='${r(n)}' and trashed=false`)}async function p(e,{name:t,folderId:a,content:i,mimeType:r},{fetchImpl:d}={}){const c=JSON.stringify({name:t,parents:[a]}),l=`--${o}\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n${c}\r\n--${o}\r\nContent-Type: ${r}\r\n\r\n${i}\r\n--${o}--`;return s(d,`${n}?uploadType=multipart&fields=${encodeURIComponent("id,webViewLink")}`,{method:"POST",accessToken:e,headers:{"Content-Type":`multipart/related; boundary=${o}`},body:l})}async function m(e,t,o,a,{fetchImpl:i}={}){return s(i,`${n}/${encodeURIComponent(t)}?uploadType=media&fields=${encodeURIComponent("id,webViewLink")}`,{method:"PATCH",accessToken:e,headers:{"Content-Type":a},body:o})}module.exports={DEFAULT_FOLDER:a,DEFAULT_FILE:i,findOrCreateFolder:c,findFileInFolder:l,createFile:p,updateFileContent:m,uploadMemoryBackup:async function(e,n,t={}){const o=t.folderName||a,r=t.fileName||i,s=t.mimeType||"application/json",d=t.fetchImpl,f=await c(e,o,{fetchImpl:d}),u=await l(e,r,f,{fetchImpl:d}),y=u?await m(e,u.id,n,s,{fetchImpl:d}):await p(e,{name:r,folderId:f,content:n,mimeType:s},{fetchImpl:d});return{fileId:y.id||u&&u.id||null,webViewLink:y.webViewLink||null,updated:Boolean(u)}}};