@andorra-labs/code 0.1.4 → 0.1.6
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/src/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +126 -20
- package/dist/src/agent-mcp.d.ts +18 -1
- package/dist/src/agent-mcp.js +103 -8
- package/dist/src/app-server/protocol.d.ts +33 -3
- package/dist/src/app-server/protocol.js +14 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +7 -1
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1229 -219
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +8 -1
- package/dist/src/automations.js +1 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.js +13 -2
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +54 -23
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/coding-tools.js +44 -5
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +10 -1
- package/dist/src/commands.js +7 -7
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +334 -17
- package/dist/src/config.d.ts +13 -0
- package/dist/src/config.js +28 -2
- package/dist/src/deadline.js +6 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +7 -0
- package/dist/src/graph-server.js +61 -3
- package/dist/src/graph-sync.d.ts +50 -0
- package/dist/src/graph-sync.js +383 -12
- package/dist/src/graph-ui/app.js +61 -8
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/style.css +19 -0
- package/dist/src/graphs.d.ts +46 -4
- package/dist/src/graphs.js +152 -27
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +2 -2
- package/dist/src/powershell-pool.js +18 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +111 -17
- package/dist/src/pull-requests.js +308 -76
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/react-runtime.js +76 -5
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/sessions.js +4 -1
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +97 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +29 -0
- package/dist/src/terminal-ui.js +112 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.js +45 -11
- package/dist/src/trajectory.js +32 -12
- package/dist/src/types.d.ts +23 -0
- package/dist/src/update.d.ts +26 -16
- package/dist/src/update.js +232 -275
- package/docs/agents/install-for-agents.md +15 -24
- package/docs/agents/mcp-server.md +13 -1
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/security.md +2 -0
- package/docs/getting-started/README.md +14 -6
- package/docs/getting-started/configure-providers.md +29 -2
- package/docs/guides/README.md +1 -1
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +45 -9
- package/docs/guides/graph-builder.md +8 -0
- package/docs/guides/update.md +37 -16
- package/docs/reference/cli.md +1 -1
- package/docs/reference/config.md +2 -2
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
package/dist/src/graph-sync.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { mkdir, readdir, readFile, rename, writeFile, link, unlink } from 'node:fs/promises';
|
|
3
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
4
|
import { join, relative } from 'node:path';
|
|
4
5
|
import { AUTH_REFRESH_BUDGET_MS, getAccessToken, getAuthConfiguration, getAuthStatus } from './auth/index.js';
|
|
5
6
|
import { decodeJwt } from 'jose';
|
|
6
7
|
import { GraphConflictError, restoreGraphRevision, validateGraph } from './graphs.js';
|
|
8
|
+
import { acquireSaveLock, removeLockedFolder, SaveLockBusyError } from './save-lock.js';
|
|
7
9
|
import { readGraphQuota } from './graph-quota.js';
|
|
8
10
|
const MAX_BYTES = 600 * 1024;
|
|
11
|
+
const DELETION_MARKER = '.graph-deletion-pending.json';
|
|
9
12
|
const digest = (raw) => createHash('sha256').update(raw).digest('hex');
|
|
10
13
|
const safeId = (id) => typeof id === 'string' && /^[\w-]{1,128}$/.test(id);
|
|
11
14
|
const safeHash = (hash) => typeof hash === 'string' && /^[a-f0-9]{64}$/.test(hash);
|
|
@@ -148,9 +151,22 @@ export class GraphSync {
|
|
|
148
151
|
const original = envelope('draft', content);
|
|
149
152
|
if (this.lastDraft.get(content.id) === digest(original))
|
|
150
153
|
return;
|
|
154
|
+
// A deleted graph's drafts die with it: a write that races the deletion's cleanup must not
|
|
155
|
+
// recreate one, or the tombstone's promise that no trace of the graph survives is broken
|
|
156
|
+
// while the machine is offline and no pruning pass removes it.
|
|
157
|
+
if ((await this.readDeletedGraphs()).has(content.id))
|
|
158
|
+
return;
|
|
151
159
|
const raw = envelope('draft', { ...content, metadata: { ...content.metadata, updatedAt: new Date().toISOString() } });
|
|
160
|
+
const path = join(this.directory, 'graph-drafts', `${digest(raw)}.json`);
|
|
152
161
|
await mkdir(join(this.directory, 'graph-drafts'), { recursive: true });
|
|
153
|
-
await atomic(
|
|
162
|
+
await atomic(path, raw);
|
|
163
|
+
// The tombstone can land while this write is in flight: forgetGraph prunes drafts only
|
|
164
|
+
// after its own cleanup, so a write that read the tombstone before the deletion must not
|
|
165
|
+
// outlive it either. The file is dropped when the graph is tombstoned by the time it landed.
|
|
166
|
+
if ((await this.readDeletedGraphs()).has(content.id)) {
|
|
167
|
+
await unlink(path).catch(() => { });
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
154
170
|
this.lastDraft.set(content.id, digest(original));
|
|
155
171
|
this.generation++;
|
|
156
172
|
this.status = { state: 'pending', detail: 'Draft saved locally; cloud sync pending' };
|
|
@@ -178,6 +194,232 @@ export class GraphSync {
|
|
|
178
194
|
throw new Error('Invalid draft');
|
|
179
195
|
return parseSnapshot(await readFile(join(this.directory, 'graph-drafts', `${hash}.json`), 'utf8'), hash).content;
|
|
180
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* The tombstones and their lineage floors are one durable record. Keeping them in one atomic
|
|
199
|
+
* replacement means a crash cannot publish a deletion without its floor (or vice versa).
|
|
200
|
+
* The legacy split files are read only for migration; the next mutation writes the combined file.
|
|
201
|
+
*/
|
|
202
|
+
async readDeletionState() {
|
|
203
|
+
const parse = (value) => {
|
|
204
|
+
const deleted = new Set();
|
|
205
|
+
const floors = Object.create(null);
|
|
206
|
+
// "pending" holds the head at deletion, not the historic cloud floor. It is paired
|
|
207
|
+
// with a marker in the old folder to distinguish interrupted removal from a new save.
|
|
208
|
+
const pending = Object.create(null);
|
|
209
|
+
if (Array.isArray(value)) {
|
|
210
|
+
for (const id of value)
|
|
211
|
+
if (safeId(id))
|
|
212
|
+
deleted.add(id);
|
|
213
|
+
}
|
|
214
|
+
else if (object(value) && Array.isArray(value.deleted) && object(value.floors)) {
|
|
215
|
+
for (const id of value.deleted)
|
|
216
|
+
if (safeId(id))
|
|
217
|
+
deleted.add(id);
|
|
218
|
+
for (const [id, floor] of Object.entries(value.floors))
|
|
219
|
+
if (safeId(id) && Number.isSafeInteger(floor) && floor >= 1)
|
|
220
|
+
floors[id] = floor;
|
|
221
|
+
if (value.pending !== undefined) {
|
|
222
|
+
if (!object(value.pending))
|
|
223
|
+
throw new Error('Invalid graph deletion pending state');
|
|
224
|
+
for (const [id, head] of Object.entries(value.pending))
|
|
225
|
+
if (safeId(id) && Number.isSafeInteger(head) && head >= 0)
|
|
226
|
+
pending[id] = head;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else
|
|
230
|
+
throw new Error('Invalid graph deletion state');
|
|
231
|
+
return { deleted, floors, pending };
|
|
232
|
+
};
|
|
233
|
+
try {
|
|
234
|
+
return parse(JSON.parse(await readFile(join(this.folder, 'deletion-state.json'), 'utf8')));
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
if (error.code !== 'ENOENT')
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
// Upgrade older installations that persisted the two parts separately.
|
|
241
|
+
let deleted;
|
|
242
|
+
let floors;
|
|
243
|
+
try {
|
|
244
|
+
const saved = JSON.parse(await readFile(join(this.folder, 'deleted-graphs.json'), 'utf8'));
|
|
245
|
+
deleted = new Set(Array.isArray(saved) ? saved.filter(safeId) : []);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if (error.code === 'ENOENT')
|
|
249
|
+
deleted = new Set();
|
|
250
|
+
else
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const saved = JSON.parse(await readFile(join(this.folder, 'deleted-revisions.json'), 'utf8'));
|
|
255
|
+
floors = Object.create(null);
|
|
256
|
+
if (object(saved))
|
|
257
|
+
for (const [id, floor] of Object.entries(saved))
|
|
258
|
+
if (safeId(id) && Number.isSafeInteger(floor) && floor >= 1)
|
|
259
|
+
floors[id] = floor;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
if (error.code === 'ENOENT')
|
|
263
|
+
floors = Object.create(null);
|
|
264
|
+
else
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
return { deleted, floors, pending: Object.create(null) };
|
|
268
|
+
}
|
|
269
|
+
async readDeletedGraphs() { return (await this.readDeletionState()).deleted; }
|
|
270
|
+
async readDeletedRevisions() { return (await this.readDeletionState()).floors; }
|
|
271
|
+
/**
|
|
272
|
+
* Read-modify-write the deletion state under one account-wide lock. Two editors deleting
|
|
273
|
+
* different graphs hold different graphs' save locks, so only a lock across the account stops
|
|
274
|
+
* one replacement from dropping the other's deletion; reviveGraph is serialized by it too.
|
|
275
|
+
* A deletion records its floor in the same lock hold, so a revival can never inherit a floor
|
|
276
|
+
* without the tombstone that justifies it.
|
|
277
|
+
*/
|
|
278
|
+
async updateDeletionState(mutate, maxAttempts = 80) {
|
|
279
|
+
const release = await this.acquireAccountLock(maxAttempts);
|
|
280
|
+
try {
|
|
281
|
+
const { deleted, floors, pending } = await this.readDeletionState();
|
|
282
|
+
if (!mutate(deleted, floors, pending))
|
|
283
|
+
return;
|
|
284
|
+
await atomic(join(this.folder, 'deletion-state.json'), JSON.stringify({ deleted: [...deleted], floors, pending }));
|
|
285
|
+
}
|
|
286
|
+
finally {
|
|
287
|
+
await release();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The account-wide lock every tombstone change and deletion tail runs under: two editors
|
|
292
|
+
* deleting different graphs hold different graphs' save locks, so only a lock across the
|
|
293
|
+
* account stops one replacement from dropping the other's deletion, and reviveGraph is
|
|
294
|
+
* serialized by it too.
|
|
295
|
+
*/
|
|
296
|
+
async acquireAccountLock(maxAttempts = 80) {
|
|
297
|
+
for (let attempt = 0;; attempt++) {
|
|
298
|
+
try {
|
|
299
|
+
return await acquireSaveLock(this.folder);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
if (!(error instanceof SaveLockBusyError))
|
|
303
|
+
throw error;
|
|
304
|
+
if (attempt >= maxAttempts)
|
|
305
|
+
throw new GraphConflictError('Another editor is updating this account. Try again.');
|
|
306
|
+
await delay(25);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The user deleted a graph. Record that before removing anything: the tombstone is written under
|
|
312
|
+
* the graph's save lock, and every later cloud restore re-reads it under the same lock, so a pass
|
|
313
|
+
* running while the delete lands cannot write the graph back. The graph's drafts die with it —
|
|
314
|
+
* each draft snapshot names a graph, and none is left to open. The newest revision the folder had
|
|
315
|
+
* reached is recorded with the tombstone: it is the floor a later revival needs to keep the old
|
|
316
|
+
* lineage's cloud revisions from advancing a replacement.
|
|
317
|
+
*/
|
|
318
|
+
async forgetGraph(id) {
|
|
319
|
+
if (!safeId(id) || id === 'default')
|
|
320
|
+
throw new Error('Invalid graph id');
|
|
321
|
+
await mkdir(this.folder, { recursive: true });
|
|
322
|
+
const folder = join(this.directory, 'graphs', id);
|
|
323
|
+
let release;
|
|
324
|
+
for (let attempt = 0; !release; attempt++) {
|
|
325
|
+
try {
|
|
326
|
+
release = await acquireSaveLock(folder);
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (!(error instanceof SaveLockBusyError))
|
|
330
|
+
throw error;
|
|
331
|
+
if (attempt >= 80)
|
|
332
|
+
throw new GraphConflictError('Wait for the current save before deleting this graph.');
|
|
333
|
+
await delay(25);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
// Acquire the account lock once and keep it continuously from the tombstone/floor commit
|
|
337
|
+
// through folder removal and draft pruning. This blocks a concurrent revival from clearing
|
|
338
|
+
// the tombstone between those steps, and every failure path releases both locks.
|
|
339
|
+
let accountRelease;
|
|
340
|
+
try {
|
|
341
|
+
accountRelease = await this.acquireAccountLock();
|
|
342
|
+
// Read while the storage is still there: after the removal the folder no longer says how
|
|
343
|
+
// far the deleted graph had come.
|
|
344
|
+
let newest = 0;
|
|
345
|
+
try {
|
|
346
|
+
const value = JSON.parse(await readFile(join(folder, 'latest.json'), 'utf8'));
|
|
347
|
+
if (Number.isSafeInteger(value) && value >= 1)
|
|
348
|
+
newest = value;
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
if (error.code !== 'ENOENT')
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
// Publish the old folder's identity before the tombstone: a crash after the tombstone
|
|
355
|
+
// but before detach leaves proof that even an uncached graph is deletion residue.
|
|
356
|
+
// A newly-created folder lacks this marker; a save to this same folder advances its head.
|
|
357
|
+
await writeFile(join(folder, DELETION_MARKER), JSON.stringify({ head: newest }), { mode: 0o600 });
|
|
358
|
+
const { deleted, floors, pending } = await this.readDeletionState();
|
|
359
|
+
let changed = false;
|
|
360
|
+
if (!deleted.has(id)) {
|
|
361
|
+
deleted.add(id);
|
|
362
|
+
changed = true;
|
|
363
|
+
}
|
|
364
|
+
// A re-created id can be deleted again: never lower a previous lineage's floor.
|
|
365
|
+
if (newest >= 1 && newest > (floors[id] ?? 0)) {
|
|
366
|
+
floors[id] = newest;
|
|
367
|
+
changed = true;
|
|
368
|
+
}
|
|
369
|
+
if (pending[id] !== newest) {
|
|
370
|
+
pending[id] = newest;
|
|
371
|
+
changed = true;
|
|
372
|
+
}
|
|
373
|
+
if (changed)
|
|
374
|
+
await atomic(join(this.folder, 'deletion-state.json'), JSON.stringify({ deleted: [...deleted], floors, pending }));
|
|
375
|
+
// The graph lock prevents restores/saves to this id; the account lock prevents revival and
|
|
376
|
+
// concurrent tombstone mutations until both the folder and drafts are gone.
|
|
377
|
+
await removeLockedFolder(folder);
|
|
378
|
+
await release();
|
|
379
|
+
await this.pruneDrafts(id);
|
|
380
|
+
this.generation++;
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
await accountRelease?.();
|
|
384
|
+
await release();
|
|
385
|
+
}
|
|
386
|
+
this.status = { state: 'pending', detail: 'Graph deleted; cloud sync pending' };
|
|
387
|
+
void this.sync();
|
|
388
|
+
}
|
|
389
|
+
/** Remove every draft that names the graph: its drafts die with it. The caller holds the account lock. */
|
|
390
|
+
async pruneDrafts(id) {
|
|
391
|
+
for (const entry of await entries(join(this.directory, 'graph-drafts'))) {
|
|
392
|
+
if (!entry.isFile() || !/^[a-f0-9]{64}\.json$/.test(entry.name))
|
|
393
|
+
continue;
|
|
394
|
+
try {
|
|
395
|
+
const raw = await readFile(join(this.directory, 'graph-drafts', entry.name), 'utf8');
|
|
396
|
+
if (parseSnapshot(raw, entry.name.slice(0, -5)).graphId !== id)
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
await unlink(join(this.directory, 'graph-drafts', entry.name)).catch(() => { });
|
|
403
|
+
}
|
|
404
|
+
this.lastDraft.delete(id);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* A graph with this id was saved again: its cloud snapshots may restore once more. The floor
|
|
408
|
+
* recorded at the deletion stays — it is what keeps the old lineage's revisions from advancing
|
|
409
|
+
* the replacement's latest pointer.
|
|
410
|
+
*/
|
|
411
|
+
async reviveGraph(id) {
|
|
412
|
+
if (!safeId(id) || id === 'default')
|
|
413
|
+
return;
|
|
414
|
+
// A slow draft prune can hold the account lock past the normal two-second budget.
|
|
415
|
+
// A successful save must not return while its tombstone remains: keep retrying the
|
|
416
|
+
// durable revival, and propagate a real failure instead of silently swallowing it.
|
|
417
|
+
await this.updateDeletionState((deleted, _floors, pending) => {
|
|
418
|
+
const changed = deleted.delete(id) || Object.hasOwn(pending, id);
|
|
419
|
+
delete pending[id];
|
|
420
|
+
return changed;
|
|
421
|
+
}, 600);
|
|
422
|
+
}
|
|
181
423
|
sync() {
|
|
182
424
|
if (this.stopped)
|
|
183
425
|
return Promise.resolve();
|
|
@@ -211,6 +453,98 @@ export class GraphSync {
|
|
|
211
453
|
throw error;
|
|
212
454
|
}
|
|
213
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* A committed tombstone has two possible local folders: the old folder an interrupted
|
|
458
|
+
* delete did not detach, or a replacement published while revival waited for the account
|
|
459
|
+
* lock. The deletion marker and head at deletion identify only the former. Legacy
|
|
460
|
+
* tombstones have no marker, so retain the existing conservative cached-head check.
|
|
461
|
+
*
|
|
462
|
+
* Lock order matches forgetGraph (graph, then account); inspect fresh state only while
|
|
463
|
+
* holding both locks, so a concurrent save/revival cannot be removed by a stale pass.
|
|
464
|
+
*/
|
|
465
|
+
async reconcileDeletedFolders(deleted) {
|
|
466
|
+
for (const id of deleted) {
|
|
467
|
+
const folder = join(this.directory, 'graphs', id);
|
|
468
|
+
try {
|
|
469
|
+
await readdir(folder);
|
|
470
|
+
}
|
|
471
|
+
catch (error) {
|
|
472
|
+
if (error.code === 'ENOENT')
|
|
473
|
+
continue;
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
let release;
|
|
477
|
+
try {
|
|
478
|
+
for (let attempt = 0; !release; attempt++) {
|
|
479
|
+
try {
|
|
480
|
+
release = await acquireSaveLock(folder);
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
if (!(error instanceof SaveLockBusyError))
|
|
484
|
+
throw error;
|
|
485
|
+
if (attempt >= 80)
|
|
486
|
+
throw new GraphConflictError('Wait for the current save before deleting this graph.');
|
|
487
|
+
await delay(25);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const accountRelease = await this.acquireAccountLock();
|
|
491
|
+
try {
|
|
492
|
+
const state = await this.readDeletionState();
|
|
493
|
+
if (!state.deleted.has(id))
|
|
494
|
+
continue;
|
|
495
|
+
let head = 0;
|
|
496
|
+
try {
|
|
497
|
+
const saved = JSON.parse(await readFile(join(folder, 'latest.json'), 'utf8'));
|
|
498
|
+
if (!Number.isSafeInteger(saved) || saved < 1)
|
|
499
|
+
continue;
|
|
500
|
+
head = saved;
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
if (error.code !== 'ENOENT')
|
|
504
|
+
throw error;
|
|
505
|
+
}
|
|
506
|
+
const pending = Object.hasOwn(state.pending, id) ? state.pending[id] : undefined;
|
|
507
|
+
if (pending !== undefined) {
|
|
508
|
+
let marker;
|
|
509
|
+
try {
|
|
510
|
+
const value = JSON.parse(await readFile(join(folder, DELETION_MARKER), 'utf8'));
|
|
511
|
+
if (object(value) && Number.isSafeInteger(value.head) && value.head >= 0)
|
|
512
|
+
marker = value.head;
|
|
513
|
+
}
|
|
514
|
+
catch { /* A missing or damaged marker is not proof of residue: preserve data. */ }
|
|
515
|
+
if (marker === pending && head === pending) {
|
|
516
|
+
await removeLockedFolder(folder);
|
|
517
|
+
await this.pruneDrafts(id);
|
|
518
|
+
}
|
|
519
|
+
else if (head >= 1) {
|
|
520
|
+
// A new folder (no marker) or an advanced head is a save performed after the
|
|
521
|
+
// tombstone. Complete its interrupted revival while preserving the old floor.
|
|
522
|
+
state.deleted.delete(id);
|
|
523
|
+
delete state.pending[id];
|
|
524
|
+
await atomic(join(this.folder, 'deletion-state.json'), JSON.stringify({ deleted: [...state.deleted], floors: state.floors, pending: state.pending }));
|
|
525
|
+
this.generation++;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
else if (head >= 1) {
|
|
529
|
+
// Legacy interrupted deletes have no marker. Only an uploaded, cached head
|
|
530
|
+
// demonstrates the old lineage, so never destroy an uncached legacy folder.
|
|
531
|
+
const hash = digest(envelope('revision', JSON.parse(await readFile(join(folder, `${head}.json`), 'utf8'))));
|
|
532
|
+
if (await this.cached(hash)) {
|
|
533
|
+
await removeLockedFolder(folder);
|
|
534
|
+
await this.pruneDrafts(id);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
finally {
|
|
539
|
+
await accountRelease();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
catch { /* Retry a locked or damaged folder on the next pass; never guess and remove it. */ }
|
|
543
|
+
finally {
|
|
544
|
+
await release?.();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
214
548
|
async request(path, token, body) {
|
|
215
549
|
this.checkBudget();
|
|
216
550
|
if (await this.deps.subject() !== this.subject)
|
|
@@ -257,19 +591,20 @@ export class GraphSync {
|
|
|
257
591
|
async perform() {
|
|
258
592
|
this.deadline = this.now() + 20_000;
|
|
259
593
|
this.status = { state: 'syncing', detail: 'Saving graphs to your account…' };
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
//
|
|
594
|
+
// Repair interrupted local deletions before network authorization: even an offline machine
|
|
595
|
+
// must not show a graph whose tombstone was committed before a crash. A save that landed
|
|
596
|
+
// after that tombstone is revived rather than removed.
|
|
597
|
+
await mkdir(join(this.folder, 'snapshots'), { recursive: true });
|
|
598
|
+
await this.reconcileDeletedFolders(await this.readDeletedGraphs());
|
|
599
|
+
const deleted = await this.readDeletedGraphs();
|
|
600
|
+
// Token acquisition may wait for a refresh rotation; check the account afterwards.
|
|
263
601
|
const token = await this.deps.token(this.closer.signal);
|
|
264
602
|
if (!token)
|
|
265
603
|
throw new Error('Sign in required');
|
|
266
604
|
if (await this.deps.subject() !== this.subject)
|
|
267
605
|
throw new Error('Account changed');
|
|
268
|
-
// The server verifies the signature; this comparison binds the captured token to
|
|
269
|
-
// the local queue even if another process changes accounts during token refresh.
|
|
270
606
|
if (decodeJwt(token).sub !== this.subject)
|
|
271
607
|
throw new Error('Account changed');
|
|
272
|
-
await mkdir(join(this.folder, 'snapshots'), { recursive: true });
|
|
273
608
|
let receipts = {};
|
|
274
609
|
try {
|
|
275
610
|
const saved = JSON.parse(await readFile(join(this.folder, 'receipts.json'), 'utf8'));
|
|
@@ -350,7 +685,11 @@ export class GraphSync {
|
|
|
350
685
|
};
|
|
351
686
|
const exhausted = () => processed >= 32 || this.now() >= localDeadline || this.stopped;
|
|
352
687
|
if (!local.drafts) {
|
|
353
|
-
|
|
688
|
+
// A folder a tombstone still names is either deletion residue (reconciled above) or a
|
|
689
|
+
// replacement whose revival has not landed yet: uploading either would put a deleted
|
|
690
|
+
// graph's revisions back into the cloud. The revival clears the tombstone, and the next
|
|
691
|
+
// sweep then uploads the replacement.
|
|
692
|
+
const dirs = (await entries(join(this.directory, 'graphs'))).filter(dir => dir.isDirectory() && safeId(dir.name) && !deleted.has(dir.name)).sort((a, b) => a.name < b.name ? -1 : 1);
|
|
354
693
|
// A free account's cloud allowance is pinned to the first graph whose revision arrives, and the
|
|
355
694
|
// graph it keeps here is its oldest. One revision of the kept graph therefore goes first in every
|
|
356
695
|
// sweep, so the two agree whatever the ids' order; one is enough to set the pin. The checkpoint
|
|
@@ -409,6 +748,21 @@ export class GraphSync {
|
|
|
409
748
|
localComplete = false;
|
|
410
749
|
break;
|
|
411
750
|
}
|
|
751
|
+
// A draft of a deleted graph is residue from a restore that raced the delete; prune it so
|
|
752
|
+
// the graph's tombstone keeps every trace of the graph off this machine.
|
|
753
|
+
if (deleted.size) {
|
|
754
|
+
try {
|
|
755
|
+
const raw = await readFile(join(this.directory, 'graph-drafts', file.name), 'utf8');
|
|
756
|
+
if (deleted.has(parseSnapshot(raw, file.name.slice(0, -5)).graphId)) {
|
|
757
|
+
await unlink(join(this.directory, 'graph-drafts', file.name)).catch(() => { });
|
|
758
|
+
local.file = file.name;
|
|
759
|
+
processed++;
|
|
760
|
+
await atomic(localPath, JSON.stringify(local));
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
catch { /* A damaged draft is left for the drafts() reader to report. */ }
|
|
765
|
+
}
|
|
412
766
|
await upload(join(this.directory, 'graph-drafts', file.name), 'draft', file.name);
|
|
413
767
|
local.file = file.name;
|
|
414
768
|
processed++;
|
|
@@ -459,7 +813,7 @@ export class GraphSync {
|
|
|
459
813
|
? await readFile(join(this.folder, 'snapshots', `${hash}.json`), 'utf8')
|
|
460
814
|
: await this.request(`/${hash}`, token);
|
|
461
815
|
// A cloud receipt proves upload, not that its user-visible copy still exists.
|
|
462
|
-
await this.restoreSnapshot(raw, hash, receipts);
|
|
816
|
+
await this.restoreSnapshot(raw, hash, receipts, deleted);
|
|
463
817
|
progress.page.remaining.shift();
|
|
464
818
|
await atomic(progressPath, JSON.stringify(progress));
|
|
465
819
|
}
|
|
@@ -492,8 +846,15 @@ export class GraphSync {
|
|
|
492
846
|
}
|
|
493
847
|
await immutable(path, raw);
|
|
494
848
|
}
|
|
495
|
-
async restoreSnapshot(raw, hash, receipts) {
|
|
849
|
+
async restoreSnapshot(raw, hash, receipts, deleted) {
|
|
496
850
|
const value = parseSnapshot(raw, hash);
|
|
851
|
+
// A graph deleted on this machine stays deleted: its snapshots stay cached but restore no
|
|
852
|
+
// more. A draft restored in the window between a delete and this verdict is pruned by the
|
|
853
|
+
// next pass over the local drafts; the revision path below closes its own race under the lock.
|
|
854
|
+
if (deleted.has(value.graphId)) {
|
|
855
|
+
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
497
858
|
// Never overwrite a local graph. Stable recovery IDs retain conflicting versions.
|
|
498
859
|
if (value.kind === 'revision') {
|
|
499
860
|
let graph;
|
|
@@ -505,14 +866,24 @@ export class GraphSync {
|
|
|
505
866
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
506
867
|
return;
|
|
507
868
|
}
|
|
869
|
+
// The guard re-reads the tombstone file under the graph's save lock, so a delete that landed
|
|
870
|
+
// while this pass was running is honored even though this pass read an older verdict.
|
|
871
|
+
let restored = true;
|
|
508
872
|
try {
|
|
509
|
-
await restoreGraphRevision(graph, this.directory);
|
|
873
|
+
({ restored } = await restoreGraphRevision(graph, this.directory, async (candidate) => (await this.readDeletedGraphs()).has(candidate.id), async (candidate) => (await this.readDeletedRevisions())[candidate.id]));
|
|
510
874
|
}
|
|
511
875
|
catch (error) {
|
|
876
|
+
// Never overwrite a local graph: a conflicting revision is kept beside the original under
|
|
877
|
+
// a stable recovery id. The recovery copy is a graph like any other, so the same deletion
|
|
878
|
+
// guard applies to it: a recovery id the user deleted is not written back either.
|
|
512
879
|
if (!(error instanceof GraphConflictError))
|
|
513
880
|
throw error;
|
|
514
881
|
graph = { ...graph, id: `cloud-${hash.slice(0, 40)}`, name: `${graph.name} (conflict r${graph.revision})`.slice(0, 120) };
|
|
515
|
-
await restoreGraphRevision(graph, this.directory);
|
|
882
|
+
({ restored } = await restoreGraphRevision(graph, this.directory, async (candidate) => (await this.readDeletedGraphs()).has(candidate.id), async (candidate) => (await this.readDeletedRevisions())[candidate.id]));
|
|
883
|
+
}
|
|
884
|
+
if (!restored) {
|
|
885
|
+
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
886
|
+
return;
|
|
516
887
|
}
|
|
517
888
|
const path = join(this.directory, 'graphs', graph.id, `${graph.revision}.json`);
|
|
518
889
|
const fingerprint = digest(await readFile(path, 'utf8'));
|
package/dist/src/graph-ui/app.js
CHANGED
|
@@ -65,11 +65,11 @@ async function api(path, body, options = {}) {
|
|
|
65
65
|
}
|
|
66
66
|
function checkpoint() { state.undo.push(copy(state.graph)); if (state.undo.length > 80) state.undo.shift(); state.redo = []; }
|
|
67
67
|
function changed() { scheduleValidation(); state.dirty = true; renderCanvas(); renderHeading(); renderValidation(); status('Unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
|
|
68
|
-
let draftTimer, pendingDraft;
|
|
68
|
+
let draftTimer, pendingDraft, draftWrite;
|
|
69
69
|
function flushDraft() {
|
|
70
70
|
clearTimeout(draftTimer);
|
|
71
71
|
const graph = pendingDraft; pendingDraft = null;
|
|
72
|
-
if (graph) return api('/api/drafts', graph).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
|
|
72
|
+
if (graph) return draftWrite = api('/api/drafts', graph).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
|
|
73
73
|
}
|
|
74
74
|
function queueDraft() {
|
|
75
75
|
if (!state.graph || !state.dirty) return;
|
|
@@ -332,6 +332,7 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
332
332
|
const button = el('button', item.label, item.danger ? 'danger' : undefined);
|
|
333
333
|
button.type = 'button'; button.setAttribute('role', 'menuitem');
|
|
334
334
|
if (item.icon) button.setAttribute('data-icon', item.icon);
|
|
335
|
+
if (item.danger) button.className = 'danger';
|
|
335
336
|
button.onclick = () => { closeGraphMenu(); item.run(); };
|
|
336
337
|
menu.append(button); buttons.push(button);
|
|
337
338
|
}
|
|
@@ -365,10 +366,14 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
365
366
|
buttons[0]?.focus?.();
|
|
366
367
|
}
|
|
367
368
|
function showGraphMenu(graph, x, y) {
|
|
368
|
-
|
|
369
|
+
const items = [
|
|
369
370
|
{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) },
|
|
370
371
|
{ label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
|
|
371
|
-
]
|
|
372
|
+
];
|
|
373
|
+
// The preset is bundled with the CLI: it has no storage to remove, and hiding it would only
|
|
374
|
+
// last until the next launch, so deletion is offered for saved graphs alone.
|
|
375
|
+
if (graph.id !== 'default') items.push({ label: 'Delete', icon: 'trash', danger: true, run: () => { deleteGraph(graph).catch(error => status(error.message, true)); } });
|
|
376
|
+
showMenuAt(x, y, `${graph.name} actions`, items);
|
|
372
377
|
}
|
|
373
378
|
function showNewGraphMenu(x, y) {
|
|
374
379
|
showMenuAt(x, y, 'Create a graph', [
|
|
@@ -418,6 +423,46 @@ async function duplicateGraph(source) {
|
|
|
418
423
|
await openGraph(created.id);
|
|
419
424
|
if (state.graph?.id === created.id) status(`Duplicated "${source.name}" - Rename it in Graph settings.`);
|
|
420
425
|
}
|
|
426
|
+
// Deleting removes the graph, its revisions and its draft history from this machine, and for a
|
|
427
|
+
// signed-in account the cloud copies stop restoring it. The confirm names that loss: there is no undo.
|
|
428
|
+
async function deleteGraph(graph) {
|
|
429
|
+
if (state.saving) { status('Wait for the current save before deleting a graph.'); return; }
|
|
430
|
+
if (!confirm(`Delete "${graph.name}"? Its revisions and drafts are removed from this machine.`)) return;
|
|
431
|
+
state.saving = true; renderHeading(); renderList();
|
|
432
|
+
// The confirm accepted the loss of unsaved edits of the deleted graph, so no draft of it may
|
|
433
|
+
// outlive it: stop its queued write, and let an in-flight one land before the deletion's
|
|
434
|
+
// cleanup rather than racing the removal it must not survive. A queued draft of the open
|
|
435
|
+
// graph is not part of this deletion: flush it before the request, so the autosave of the
|
|
436
|
+
// graph the user kept is neither discarded nor left writing during the rail refresh.
|
|
437
|
+
if (!pendingDraft || pendingDraft.id === graph.id) { pendingDraft = null; clearTimeout(draftTimer); }
|
|
438
|
+
else void flushDraft();
|
|
439
|
+
await draftWrite?.catch(() => {});
|
|
440
|
+
let deleted = false;
|
|
441
|
+
try {
|
|
442
|
+
await api(`/api/graphs/${encodeURIComponent(graph.id)}`, undefined, { method: 'DELETE' });
|
|
443
|
+
deleted = true;
|
|
444
|
+
state.graphs = state.graphs.filter(item => item.id !== graph.id);
|
|
445
|
+
// The free allowance pinned this graph: a stale kept id would mark a replacement read-only
|
|
446
|
+
// through issues(), so the plan's pointer steps aside the way a reload would recompute it.
|
|
447
|
+
if (state.plan?.freeGraphId === graph.id) delete state.plan.freeGraphId;
|
|
448
|
+
await refreshDrafts().catch(() => {});
|
|
449
|
+
} catch (error) {
|
|
450
|
+
status(error.message, true);
|
|
451
|
+
// The deletion cancelled the open graph's queued autosave. When the same graph survives the
|
|
452
|
+
// failed request and nothing re-queued a draft while it ran, queue one again: otherwise the
|
|
453
|
+
// edits the confirm was about to discard stay out of draft history until the next edit.
|
|
454
|
+
if (state.graph?.id === graph.id && state.dirty && !pendingDraft) queueDraft();
|
|
455
|
+
}
|
|
456
|
+
state.saving = false; renderHeading(); renderList();
|
|
457
|
+
if (!deleted) return;
|
|
458
|
+
if (state.graph?.id === graph.id) {
|
|
459
|
+
// The open graph is gone: a later save would recreate it, so fall back to the preset. The
|
|
460
|
+
// delete already confirmed the loss of unsaved edits, so skip the second confirmation.
|
|
461
|
+
state.dirty = false; pendingDraft = null; clearTimeout(draftTimer);
|
|
462
|
+
await openGraph('default');
|
|
463
|
+
}
|
|
464
|
+
if (state.graph?.id !== graph.id) status(`Deleted "${graph.name}".`);
|
|
465
|
+
}
|
|
421
466
|
function position(node, index) { return node.position || { x: index * 290, y: 0 }; }
|
|
422
467
|
function transform() { $('scene').style.transform = `translate(${state.x}px,${state.y}px) scale(${state.zoom})`; $('zoom').textContent = `${Math.round(state.zoom * 100)}%`; window.AndorraStudio?.viewport?.(); }
|
|
423
468
|
// The canvas tips show until the reader dismisses them once. The choice is a per-browser
|
|
@@ -700,9 +745,16 @@ function promptField(parent, label, value, onChange, options = {}) {
|
|
|
700
745
|
expand.onclick = event => { event?.preventDefault?.(); event?.stopPropagation?.(); setFullscreen(!isFullscreen()); };
|
|
701
746
|
input.addEventListener?.('keydown', event => { if (event.key === 'Escape' && isFullscreen()) { event.preventDefault(); setFullscreen(false); } });
|
|
702
747
|
setFullscreen(false); wrapper.append(expand);
|
|
748
|
+
skillPrompt(input);
|
|
703
749
|
setTimeout(grow, 0);
|
|
704
750
|
return input;
|
|
705
751
|
}
|
|
752
|
+
// Typing `/` in a prompt opens this machine's skills (skill-picker.js); a `/name` none of them
|
|
753
|
+
// answers to is a warning under the field, never a validation error.
|
|
754
|
+
function skillPrompt(input) {
|
|
755
|
+
globalThis.AndorraSkillPicker?.attach?.(input, { load: () => api('/api/skills') });
|
|
756
|
+
return input;
|
|
757
|
+
}
|
|
706
758
|
// A provider the graph names but this machine does not configure is a warning, not a model name.
|
|
707
759
|
function providerWarning(parent, providerId) {
|
|
708
760
|
const chip = el('p', undefined, 'chip chip-warning provider-warning'); chip.setAttribute('role', 'status');
|
|
@@ -1239,8 +1291,8 @@ function renderInspector() {
|
|
|
1239
1291
|
const general = panels.general; field(general, 'Name', node.name, value => {node.name=value;}, {maxLength:200});
|
|
1240
1292
|
if (node.type === 'agent') {
|
|
1241
1293
|
if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator - optional starting Agent for research, clarification and handoff. Remove it to start directly at the next node.','help'));explain(field(general,'Max subagents',node.maxSubagents,value=>{if(value===undefined)delete node.maxSubagents;else node.maxSubagents=value;},{type:'number',optional:true,min:0,max:100}),'Optional ceiling, not a target. Leave blank to use the configured subagent policy default. Zero disables internal subagents; this does not control top-level graph concurrency.');}
|
|
1242
|
-
const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;});
|
|
1243
|
-
explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this node\'s instructions; project guidance, advanced system instructions and runtime permissions still apply.');
|
|
1294
|
+
const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;}, { placeholder: 'Type / to add a skill' });
|
|
1295
|
+
explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this node\'s instructions; project guidance, advanced system instructions and runtime permissions still apply. Type / to add a skill: the node loads every /skill its prompt names when it runs. A skill this machine does not have is flagged here and skipped at run time; it never stops the graph.');
|
|
1244
1296
|
explain(check(general, 'Jev decisions', node.jevEnabled === true, value => { if (value) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists this agent with routing decisions. The coding model still implements the task; sign-in, quota and runtime permissions apply.');
|
|
1245
1297
|
const model = panels.model;
|
|
1246
1298
|
modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
|
|
@@ -1266,7 +1318,7 @@ function renderInspector() {
|
|
|
1266
1318
|
// Tool calls default to blank, and blank means unlimited: an absent limit is only
|
|
1267
1319
|
// written when the field is cleared, so a node keeps its ceiling once one is set.
|
|
1268
1320
|
field(limits,'Tool calls (blank = unlimited)',node.limits?.maxToolCalls,value=>{node.limits={...node.limits,maxToolCalls:value}; if(value===undefined)delete node.limits.maxToolCalls;},{type:'number',min:0,optional:true,placeholder:'Unlimited'});
|
|
1269
|
-
field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000}); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retry attempts',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};});
|
|
1321
|
+
skillPrompt(field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000})); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retry attempts',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};});
|
|
1270
1322
|
field(advanced,'Executor','react-basic',()=>{}).disabled=true;
|
|
1271
1323
|
const tools = disclosure(advanced,'Tool allowlist');
|
|
1272
1324
|
for (const name of [...new Set([...state.tools.map(t=>typeof t==='string'?t:t.name||t.id),...(node.tools||[])])]) check(tools,name,node.tools===undefined||node.tools.includes(name),enabled=>{const all=state.tools.map(t=>typeof t==='string'?t:t.name||t.id); node.tools=enabled?[...new Set([...(node.tools??all),name])]:(node.tools??all).filter(t=>t!==name);});
|
|
@@ -1453,12 +1505,13 @@ function copyAgent(definition) {
|
|
|
1453
1505
|
function addAgent() {
|
|
1454
1506
|
const name = el('input'); name.required = true; name.maxLength = 200;
|
|
1455
1507
|
const description = el('input'); description.maxLength = 2000;
|
|
1456
|
-
const instruction = el('textarea'); instruction.maxLength = 100000; instruction.rows = 5;
|
|
1508
|
+
const instruction = el('textarea'); instruction.maxLength = 100000; instruction.rows = 5; instruction.placeholder = 'Type / to add a skill';
|
|
1457
1509
|
const id = `definition-${crypto.randomUUID()}`;
|
|
1458
1510
|
libraryDialog('Add agent', [['Agent name', name], ['Description', description], ['Instructions', instruction]], async () => {
|
|
1459
1511
|
const agentName = requireAgentName(name);
|
|
1460
1512
|
await writeDefinition({schemaVersion:2, id, name:agentName, description:description.value.trim(), revision:0, node:{id:'agent', type:'agent', name:agentName, ...blankAgentSettings(), instruction:instruction.value.trim()}}, `Agent ${agentName} added`);
|
|
1461
1513
|
}, 'Add agent');
|
|
1514
|
+
skillPrompt(instruction);
|
|
1462
1515
|
}
|
|
1463
1516
|
// The server's 512 KiB limit applies to the import request, not the file: Share pretty-prints its
|
|
1464
1517
|
// file, so a file over that limit can still make a request under it. The request is measured
|
|
@@ -32,6 +32,7 @@ globalThis.AndorraIcons = (() => {
|
|
|
32
32
|
template: '<rect width="18" height="7" x="3" y="3" rx="1"/><rect width="9" height="7" x="3" y="14" rx="1"/><rect width="5" height="7" x="16" y="14" rx="1"/>',
|
|
33
33
|
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',
|
|
34
34
|
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',
|
|
35
|
+
trash: '<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',
|
|
35
36
|
history: '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>',
|
|
36
37
|
refresh: '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',
|
|
37
38
|
bell: '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',
|