rpg-engine 0.23.1 → 0.24.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/README.md +2 -2
- package/dist/campaign/create-campaign.d.ts +1 -1
- package/dist/campaign/create-campaign.js +1 -1
- package/dist/campaign/find-campaign.js +11 -1
- package/dist/campaign/host-files.d.ts +5 -6
- package/dist/campaign/host-files.js +100 -60
- package/dist/campaign/settings.d.ts +3 -3
- package/dist/campaign/settings.js +5 -4
- package/dist/cli/cli.js +11 -2
- package/dist/commands/config/config.js +1 -1
- package/dist/commands/config/dashboard.js +23 -6
- package/dist/commands/config/words.js +1 -0
- package/dist/commands/image.js +3 -3
- package/dist/commands/import/import.d.ts +3 -1
- package/dist/commands/import/import.js +13 -5
- package/dist/commands/instructions.js +1 -1
- package/dist/commands/shared/campaign/images.js +3 -2
- package/dist/commands/shared/campaign/mode.js +1 -1
- package/dist/commands/shared/characters/voices.d.ts +2 -2
- package/dist/commands/shared/characters/voices.js +9 -9
- package/dist/commands/shared/sheet/sheet.d.ts +2 -2
- package/dist/commands/shared/sheet/sheet.js +3 -3
- package/dist/core/context.d.ts +8 -2
- package/dist/dashboard/acts/acts.js +39 -11
- package/dist/dashboard/acts/head.js +7 -0
- package/dist/dashboard/acts/names.js +4 -2
- package/dist/dashboard/acts/sending.js +23 -22
- package/dist/dashboard/acts/sheet.js +7 -149
- package/dist/dashboard/acts/strip.js +10 -14
- package/dist/dashboard/acts/talk.js +51 -0
- package/dist/dashboard/acts/thing.js +169 -0
- package/dist/dashboard/app.js +3 -3
- package/dist/dashboard/guide/ar.md +13 -13
- package/dist/dashboard/guide/cs.md +12 -12
- package/dist/dashboard/guide/da.md +12 -12
- package/dist/dashboard/guide/de.md +11 -11
- package/dist/dashboard/guide/el.md +11 -11
- package/dist/dashboard/guide/en.md +10 -10
- package/dist/dashboard/guide/es.md +11 -11
- package/dist/dashboard/guide/fi.md +11 -11
- package/dist/dashboard/guide/fr.md +12 -12
- package/dist/dashboard/guide/he.md +11 -11
- package/dist/dashboard/guide/hi.md +11 -11
- package/dist/dashboard/guide/hu.md +11 -11
- package/dist/dashboard/guide/is.md +11 -11
- package/dist/dashboard/guide/it.md +38 -38
- package/dist/dashboard/guide/ja.md +11 -11
- package/dist/dashboard/guide/ko.md +12 -12
- package/dist/dashboard/guide/nb.md +11 -11
- package/dist/dashboard/guide/nl.md +11 -11
- package/dist/dashboard/guide/pl.md +11 -11
- package/dist/dashboard/guide/pt.md +11 -11
- package/dist/dashboard/guide/ro.md +12 -12
- package/dist/dashboard/guide/ru.md +12 -12
- package/dist/dashboard/guide/sv.md +12 -12
- package/dist/dashboard/guide/tr.md +12 -12
- package/dist/dashboard/guide/uk.md +11 -11
- package/dist/dashboard/guide/zh.md +12 -12
- package/dist/dashboard/i18n/ar.json +24 -10
- package/dist/dashboard/i18n/cs.json +24 -10
- package/dist/dashboard/i18n/da.json +24 -10
- package/dist/dashboard/i18n/de.json +24 -10
- package/dist/dashboard/i18n/el.json +24 -10
- package/dist/dashboard/i18n/es.json +24 -10
- package/dist/dashboard/i18n/fi.json +24 -10
- package/dist/dashboard/i18n/fr.json +24 -10
- package/dist/dashboard/i18n/he.json +24 -10
- package/dist/dashboard/i18n/hi.json +24 -10
- package/dist/dashboard/i18n/hu.json +24 -10
- package/dist/dashboard/i18n/is.json +24 -10
- package/dist/dashboard/i18n/it.json +102 -88
- package/dist/dashboard/i18n/ja.json +24 -10
- package/dist/dashboard/i18n/ko.json +24 -10
- package/dist/dashboard/i18n/nb.json +24 -10
- package/dist/dashboard/i18n/nl.json +24 -10
- package/dist/dashboard/i18n/pl.json +24 -10
- package/dist/dashboard/i18n/pt.json +24 -10
- package/dist/dashboard/i18n/ro.json +24 -10
- package/dist/dashboard/i18n/ru.json +24 -10
- package/dist/dashboard/i18n/sv.json +24 -10
- package/dist/dashboard/i18n/tr.json +24 -10
- package/dist/dashboard/i18n/uk.json +24 -10
- package/dist/dashboard/i18n/zh.json +24 -10
- package/dist/dashboard/packages/packages.js +1 -1
- package/dist/dashboard/parts/icons.js +2 -0
- package/dist/dashboard/parts/labels.js +1 -0
- package/dist/dashboard/parts/layout.js +34 -0
- package/dist/dashboard/parts/widgets.js +6 -2
- package/dist/dashboard/settings/language-choice.js +1 -1
- package/dist/dashboard/settings/settings.js +61 -36
- package/dist/dashboard/settings/tabs.js +14 -0
- package/dist/dashboard/sheet/sheet.js +54 -33
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/style.css +122 -47
- package/dist/helpers/antigravity.d.ts +47 -0
- package/dist/helpers/antigravity.js +434 -0
- package/dist/helpers/chosen.d.ts +11 -7
- package/dist/helpers/chosen.js +64 -37
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +2 -1
- package/dist/helpers/opencode.js +117 -24
- package/dist/helpers/programs.d.ts +8 -0
- package/dist/helpers/programs.js +35 -2
- package/dist/helpers/stop.d.ts +2 -0
- package/dist/helpers/stop.js +20 -1
- package/dist/helpers/svg.d.ts +4 -1
- package/dist/helpers/svg.js +16 -4
- package/dist/instructions/index.d.ts +4 -2
- package/dist/instructions/index.js +6 -3
- package/dist/server/bell/antigravity.d.ts +7 -2
- package/dist/server/bell/antigravity.js +24 -6
- package/dist/server/bell/index.d.ts +1 -1
- package/dist/server/bell/index.js +1 -1
- package/dist/server/bell/listener.js +6 -1
- package/dist/server/fence.d.ts +21 -0
- package/dist/server/fence.js +69 -0
- package/dist/server/mcp.js +26 -0
- package/dist/server/player-acts.js +1 -1
- package/dist/server/subagent.d.ts +4 -0
- package/dist/server/subagent.js +30 -0
- package/instructions/voices-antigravity.md +1 -0
- package/instructions/voices-codex.md +1 -0
- package/instructions/voices-opencode.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
// Antigravity does the work outside the chat where it is the chat in use (D-579 (1)): the writer of text and the importer; and it paints the pictures where
|
|
2
|
+
// the campaign chose it (T-251). The engine starts its agy with the
|
|
3
|
+
// player's own login and model, in an empty folder of its own, never in the campaign's tree, with a home of the engine's, so that it starts none of the
|
|
4
|
+
// player's global servers and leaves nothing in their history; settings of the engine's and its hook fence it, and the brief goes as one stream-json message on
|
|
5
|
+
// its input. Each start keeps all it makes in one temporary folder, which names its process: what a run stopped from outside left is swept by the next.
|
|
6
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
7
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { rm } from "node:fs/promises";
|
|
9
|
+
import { homedir, tmpdir } from "node:os";
|
|
10
|
+
import { join, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { isAlive } from "../core/process-mark.js";
|
|
13
|
+
import { chatBrief } from "./briefs.js";
|
|
14
|
+
import { chatEnvironment, isOwn, knownReady } from "./programs.js";
|
|
15
|
+
import { stopProcess, stopTree, whenEnded } from "./stop.js";
|
|
16
|
+
// The same limits as Claude's: a brief in three minutes, a run of the importer in thirty.
|
|
17
|
+
const longest = 3 * 60 * 1000;
|
|
18
|
+
const longestReading = 30 * 60 * 1000;
|
|
19
|
+
// How old a run's folder that names no process may be before a sweep takes it.
|
|
20
|
+
const unownedAge = 60 * 60 * 1000;
|
|
21
|
+
// The beginning of the name of every run's folder in the temporary folder.
|
|
22
|
+
const runPrefix = "rpg-agy-";
|
|
23
|
+
/**
|
|
24
|
+
* Antigravity on this computer as a writer of text (D-579 (1)): agy, sealed by settings of the engine's and refused every tool by its hook, in an empty folder
|
|
25
|
+
* of its own. `program` is the line that starts it, `home` the player's real home, where their model is chosen.
|
|
26
|
+
*/
|
|
27
|
+
export function antigravityWriter(program = "agy", home = homedir()) {
|
|
28
|
+
const ready = antigravityReady(program);
|
|
29
|
+
return {
|
|
30
|
+
ready: () => ready().ready,
|
|
31
|
+
write: async (brief) => {
|
|
32
|
+
if (!ready().ready) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const run = runFolder();
|
|
36
|
+
try {
|
|
37
|
+
prepareRun(run, sealedSettings(run.work, playerModel(home)), { read: [], write: [] });
|
|
38
|
+
const ran = await runAgy(program, run, brief, longest);
|
|
39
|
+
return ran.code === 0 && ran.status === "SUCCESS" ? ran.response : undefined;
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
dropFolder(run.root);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Antigravity on this computer as the importer (D-579 (1)): agy in an empty folder of its own, reaching the import's folder by its full path, allowed to read
|
|
49
|
+
* there and to write only in the folders given; its hook refuses any other call, and the settings close the run that makes one anyway.
|
|
50
|
+
*/
|
|
51
|
+
export function antigravityReader(program = "agy", home = homedir()) {
|
|
52
|
+
const ready = antigravityReady(program);
|
|
53
|
+
return {
|
|
54
|
+
ready: () => ready().ready,
|
|
55
|
+
program: () => "Antigravity",
|
|
56
|
+
clean: () => void sweep(),
|
|
57
|
+
read: async (given, brief, writable, signal) => {
|
|
58
|
+
const said = ready();
|
|
59
|
+
if (!said.ready) {
|
|
60
|
+
return { failed: said.why };
|
|
61
|
+
}
|
|
62
|
+
// Never in the campaign's tree, whose hooks and instructions agy would take as its own.
|
|
63
|
+
const run = runFolder();
|
|
64
|
+
try {
|
|
65
|
+
// agy checks real paths: a folder behind a link would match none of its rules.
|
|
66
|
+
const folder = realPath(given);
|
|
67
|
+
const writeFolders = writable.map((name) => join(folder, name));
|
|
68
|
+
prepareRun(run, readerSettings(folder, run.work, writable, playerModel(home)), { read: [folder, ...writeFolders], write: writeFolders });
|
|
69
|
+
const ran = await runAgy(program, run, `${placeOf(folder)}\n\n${brief}`, longestReading, signal);
|
|
70
|
+
return readingAnswer(ran);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
dropFolder(run.root);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Why Antigravity paints no pictures, for the master and the player (T-251): the engine never installs it, so there is no step to give. */
|
|
79
|
+
export const antigravitySays = { notReady: { why: "Antigravity's agy does not answer on this computer, or is not signed in" } };
|
|
80
|
+
/**
|
|
81
|
+
* Antigravity on this computer as the painter, where the campaign chose it and another host is the chat (T-251): agy in an empty folder of its own, with its
|
|
82
|
+
* image tool and the two it calls it with let through, every other refused; the picture it saves in its own data folder, under its home of the engine's.
|
|
83
|
+
*/
|
|
84
|
+
export function antigravityPainter(program = "agy", home = homedir()) {
|
|
85
|
+
const ready = antigravityReady(program);
|
|
86
|
+
return {
|
|
87
|
+
ready,
|
|
88
|
+
make: async (subject) => {
|
|
89
|
+
const said = ready();
|
|
90
|
+
if (!said.ready) {
|
|
91
|
+
return { refused: said.why };
|
|
92
|
+
}
|
|
93
|
+
const run = runFolder();
|
|
94
|
+
try {
|
|
95
|
+
prepareRun(run, painterSettings(run.work, playerModel(home)), { read: [], write: [], tools: painterTools });
|
|
96
|
+
const ran = await runAgy(program, run, chatBrief(subject), longestPainting);
|
|
97
|
+
const file = newestPicture(join(run.home, ".gemini", "antigravity-cli", "brain"));
|
|
98
|
+
// The folder stays until the engine copied the picture.
|
|
99
|
+
if (file !== undefined) {
|
|
100
|
+
return { file, done: () => dropFolder(run.root) };
|
|
101
|
+
}
|
|
102
|
+
dropFolder(run.root);
|
|
103
|
+
const words = ran.error ?? ran.response?.split("\n")[0]?.trim();
|
|
104
|
+
return words === undefined || words === "" ? { refused: "Antigravity made no picture, and said nothing", onlyThis: true } : { refused: `Antigravity made no picture: ${words}` };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
dropFolder(run.root);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** The painter's settings: its working folder trusted, the player's model, and every command, MCP tool and URL denied. */
|
|
114
|
+
export function painterSettings(work, model) {
|
|
115
|
+
return { trustedWorkspaces: [work], ...modelOf(model), permissions: { deny: ["command(*)", "mcp(*)", "read_url(*)", "execute_url(*)", "download_url(*)"] } };
|
|
116
|
+
}
|
|
117
|
+
// The tools the painter calls, as the real run of 22 November did: its image tool, and the subagent and message it uses to reach it.
|
|
118
|
+
const painterTools = ["invoke_subagent", "generate_image", "send_message"];
|
|
119
|
+
// A picture in five minutes: the real run's took 52 seconds.
|
|
120
|
+
const longestPainting = 5 * 60 * 1000;
|
|
121
|
+
// The pictures agy saves, by their names' ends.
|
|
122
|
+
const pictureFile = /\.(png|jpe?g|webp)$/i;
|
|
123
|
+
/** The newest picture under `folder`, at any depth, but none under a .system_generated folder, which holds agy's own copies; undefined where there is none. */
|
|
124
|
+
function newestPicture(folder) {
|
|
125
|
+
let newest;
|
|
126
|
+
const look = (here) => {
|
|
127
|
+
let entries;
|
|
128
|
+
try {
|
|
129
|
+
entries = readdirSync(here, { withFileTypes: true });
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
for (const entry of entries) {
|
|
135
|
+
const path = join(here, entry.name);
|
|
136
|
+
if (entry.isDirectory() && entry.name !== ".system_generated") {
|
|
137
|
+
look(path);
|
|
138
|
+
}
|
|
139
|
+
else if (entry.isFile() && pictureFile.test(entry.name)) {
|
|
140
|
+
const time = statSync(path).mtimeMs;
|
|
141
|
+
newest = newest === undefined || time > newest.time ? { path, time } : newest;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
look(folder);
|
|
146
|
+
return newest?.path;
|
|
147
|
+
}
|
|
148
|
+
/** The writer's settings: `folder` trusted, the player's model, and every command, MCP tool, URL and file of the computer's `roots` denied. */
|
|
149
|
+
export function sealedSettings(folder, model, roots = computerRoots()) {
|
|
150
|
+
const files = roots.flatMap((root) => [`read_file(${root})`, `write_file(${root})`]);
|
|
151
|
+
return { trustedWorkspaces: [folder], ...modelOf(model), permissions: { deny: ["command(*)", "mcp(*)", "read_url(*)", "execute_url(*)", ...files] } };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The importer's settings: its working folder trusted, the player's model, reading in the import's `folder` and writing in its `writable` subfolders, by their
|
|
155
|
+
* full paths; commands, MCP tools and URLs denied. No drive is denied, as a deny wins over an allow beneath it.
|
|
156
|
+
*/
|
|
157
|
+
export function readerSettings(folder, work, writable, model) {
|
|
158
|
+
return {
|
|
159
|
+
trustedWorkspaces: [work],
|
|
160
|
+
...modelOf(model),
|
|
161
|
+
permissions: {
|
|
162
|
+
allow: [`read_file(${folder})`, ...writable.map((name) => `write_file(${join(folder, name)})`)],
|
|
163
|
+
deny: ["command(*)", "mcp(*)", "read_url(*)", "execute_url(*)", "download_url(*)"],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The model the player chose in Antigravity, from its settings in their real `home`; undefined where there is none. */
|
|
168
|
+
export function playerModel(home) {
|
|
169
|
+
try {
|
|
170
|
+
const text = readFileSync(join(home, ".gemini", "antigravity-cli", "settings.json"), "utf8").replace(/^/, "");
|
|
171
|
+
const settings = JSON.parse(text);
|
|
172
|
+
return typeof settings.model === "string" ? settings.model : undefined;
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Takes away what runs stopped from outside left, as by an import's cancel: each run's folder whose engine process is gone, its agy stopped first if it still
|
|
180
|
+
* runs, and a folder that names no process once it is an hour old. Never throws.
|
|
181
|
+
*/
|
|
182
|
+
export async function sweep() {
|
|
183
|
+
try {
|
|
184
|
+
const names = readdirSync(tmpdir()).filter((name) => name.startsWith(runPrefix));
|
|
185
|
+
await Promise.all(names.map((name) => sweepOne(join(tmpdir(), name))));
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// The temporary folder unread: the next sweep tries again.
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* One run of agy in its folder: the brief as a stream-json message, its input closed once the result came, as agy then ends. It runs at low effort, and once
|
|
193
|
+
* more without where agy refuses it for the model, at once and without spending. Stopped after `limit`, or by `signal`.
|
|
194
|
+
*/
|
|
195
|
+
async function runAgy(program, run, brief, limit, signal) {
|
|
196
|
+
const first = await runOnce(program, run, brief, limit, true, signal);
|
|
197
|
+
// Only agy's own refusal of the effort: a run that died otherwise is never run again, as it may have spent half an hour.
|
|
198
|
+
if (first.stopped || first.run.code === 0 || !/--effort/.test(first.run.error ?? "")) {
|
|
199
|
+
return first.run;
|
|
200
|
+
}
|
|
201
|
+
return (await runOnce(program, run, brief, limit, false, signal)).run;
|
|
202
|
+
}
|
|
203
|
+
// A new run's folder, swept for what dead runs left first; its owner is this process.
|
|
204
|
+
function runFolder() {
|
|
205
|
+
void sweep();
|
|
206
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), runPrefix)));
|
|
207
|
+
writeOwner(root, { engine: process.pid });
|
|
208
|
+
mkdirSync(join(root, "home"));
|
|
209
|
+
mkdirSync(join(root, "work"));
|
|
210
|
+
return { root, home: join(root, "home"), work: join(root, "work") };
|
|
211
|
+
}
|
|
212
|
+
// The settings, the fence and the hook of a run, in its folder: the hook in its working folder, where agy reads it.
|
|
213
|
+
function prepareRun(run, settings, fence) {
|
|
214
|
+
writeFileSync(join(run.root, "settings.json"), JSON.stringify(settings));
|
|
215
|
+
writeFileSync(join(run.root, "fence.json"), JSON.stringify(fence));
|
|
216
|
+
mkdirSync(join(run.work, ".agents"));
|
|
217
|
+
writeFileSync(join(run.work, ".agents", "hooks.json"), JSON.stringify(fenceHooks(join(run.root, "fence.json"))));
|
|
218
|
+
}
|
|
219
|
+
// The importer's answer from its run: its words, or why it stopped, the run closed by the settings told apart.
|
|
220
|
+
function readingAnswer(ran) {
|
|
221
|
+
const done = ran.code === 0 && ran.status === "SUCCESS";
|
|
222
|
+
if (done && ran.response !== undefined) {
|
|
223
|
+
return { said: ran.response };
|
|
224
|
+
}
|
|
225
|
+
if (done && ran.denied !== undefined) {
|
|
226
|
+
const names = ran.denied.length === 0 ? "" : ` (${ran.denied.join(", ")})`;
|
|
227
|
+
return { failed: `Antigravity was stopped as it asked for something outside the import's folder${names}` };
|
|
228
|
+
}
|
|
229
|
+
return { failed: ran.error === undefined ? "Antigravity stopped without an answer" : `Antigravity said: ${ran.error}` };
|
|
230
|
+
}
|
|
231
|
+
// What the reader says before the engine's brief, whose paths are the import folder's while agy works elsewhere.
|
|
232
|
+
function placeOf(folder) {
|
|
233
|
+
return `${folder} is the folder this brief calls "this folder". Every path of the brief is inside it: read and write each by its full path, as `
|
|
234
|
+
+ `${join(folder, "notes", "notes.md")}. Nothing outside it can be read or written.`;
|
|
235
|
+
}
|
|
236
|
+
// This engine's own command line, the file beside this module: never the script that started this process, which may be another program's, and which the
|
|
237
|
+
// hook would then start again at every tool, each start with a run of its own.
|
|
238
|
+
const engineScript = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "../cli/cli.ts" : "../cli/cli.js", import.meta.url));
|
|
239
|
+
// The hook of a run's working folder: before every tool, this engine's own rpg --fence with the fence file, by full paths; an rpg of the PATH may be older,
|
|
240
|
+
// or not found from the home agy is given.
|
|
241
|
+
function fenceHooks(fence) {
|
|
242
|
+
const command = `"${process.execPath}" "${engineScript}" --fence "${fence}"`;
|
|
243
|
+
return { rpg: { PreToolUse: [{ matcher: ".*", hooks: [{ type: "command", command, timeout: 10 }] }] } };
|
|
244
|
+
}
|
|
245
|
+
function modelOf(model) {
|
|
246
|
+
return model === undefined ? {} : { model };
|
|
247
|
+
}
|
|
248
|
+
// A folder by its real path, where it has one.
|
|
249
|
+
function realPath(folder) {
|
|
250
|
+
try {
|
|
251
|
+
return realpathSync(folder);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return resolve(folder);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// The drives of this computer, every file of which the writer is denied: on Windows each letter that is there, elsewhere the root.
|
|
258
|
+
function computerRoots() {
|
|
259
|
+
if (process.platform !== "win32") {
|
|
260
|
+
return ["/"];
|
|
261
|
+
}
|
|
262
|
+
return Array.from({ length: 26 }, (_, index) => `${String.fromCharCode(65 + index)}:\\`).filter((root) => existsSync(root));
|
|
263
|
+
}
|
|
264
|
+
// Whether agy is ready, by the line that starts it: asked once, as the other helpers are, and remembered.
|
|
265
|
+
const readies = new Map();
|
|
266
|
+
function antigravityReady(program) {
|
|
267
|
+
const known = readies.get(program) ?? knownReady(() => modelsListed(program));
|
|
268
|
+
readies.set(program, known);
|
|
269
|
+
// Never from inside a run of the engine's helper: whatever starts there starts no agy of its own, or each run would start more.
|
|
270
|
+
return (again) => (process.env.RPG_HELPER === "1" ? { ready: false, why: "this is already a run of RPG Engine's helper, which starts no other" } : known(again));
|
|
271
|
+
}
|
|
272
|
+
/** Ready where agy lists its models, which it does only signed in, without starting one. */
|
|
273
|
+
function modelsListed(program) {
|
|
274
|
+
const run = runFolder();
|
|
275
|
+
try {
|
|
276
|
+
const listed = spawnSync(`${program} models`, { shell: true, encoding: "utf8", timeout: 15_000, windowsHide: true, cwd: run.work, env: agyEnvironment(run.home) });
|
|
277
|
+
return listed.error === undefined && listed.status === 0 ? { ready: true, maker: "Antigravity" } : { ready: false, ...antigravitySays.notReady };
|
|
278
|
+
}
|
|
279
|
+
finally {
|
|
280
|
+
dropFolder(run.root);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** One run of agy, with its effort or without: what it gave, whether a result came, and whether it was stopped. */
|
|
284
|
+
function runOnce(program, run, brief, limit, effort, signal) {
|
|
285
|
+
// The mode always given: the default differs by account.
|
|
286
|
+
const line = `${program} --print= --input-format stream-json --output-format stream-json --mode accept-edits${effort ? " --effort low" : ""} --settings "${join(run.root, "settings.json")}"`;
|
|
287
|
+
return new Promise((done) => {
|
|
288
|
+
// Off Windows it leads a group of its own: the shell alone, stopped, would leave agy running with the output held open.
|
|
289
|
+
const child = spawn(line, { shell: true, windowsHide: true, cwd: run.work, env: agyEnvironment(run.home), stdio: ["pipe", "pipe", "pipe"], detached: process.platform !== "win32" });
|
|
290
|
+
let stopped = false;
|
|
291
|
+
if (child.pid !== undefined) {
|
|
292
|
+
writeOwner(run.root, { engine: process.pid, agy: child.pid });
|
|
293
|
+
}
|
|
294
|
+
const stop = () => {
|
|
295
|
+
stopped = true;
|
|
296
|
+
if (process.platform === "win32" || child.pid === undefined) {
|
|
297
|
+
stopTree(child);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
stopProcess(child.pid);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
304
|
+
const timer = setTimeout(stop, limit);
|
|
305
|
+
let pending = "";
|
|
306
|
+
let result;
|
|
307
|
+
const hear = (text) => {
|
|
308
|
+
const event = eventOf(text);
|
|
309
|
+
// The result came: its input closed, agy ends by itself.
|
|
310
|
+
if (event?.event === "result" && result === undefined) {
|
|
311
|
+
result = event.result ?? {};
|
|
312
|
+
child.stdin.end();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
child.stdout.setEncoding("utf8");
|
|
316
|
+
child.stderr.resume();
|
|
317
|
+
child.stdout.on("data", (chunk) => {
|
|
318
|
+
const lines = (pending + chunk).split("\n");
|
|
319
|
+
pending = lines.pop() ?? "";
|
|
320
|
+
lines.forEach(hear);
|
|
321
|
+
});
|
|
322
|
+
child.stdin.on("error", () => undefined);
|
|
323
|
+
child.on("error", () => undefined);
|
|
324
|
+
whenEnded(child, (code) => {
|
|
325
|
+
clearTimeout(timer);
|
|
326
|
+
signal?.removeEventListener("abort", stop);
|
|
327
|
+
hear(pending);
|
|
328
|
+
done({ run: runOf(code, result, stopped), result: result !== undefined, stopped });
|
|
329
|
+
});
|
|
330
|
+
// The brief as one user message; the input stays open until the result comes.
|
|
331
|
+
child.stdin.write(`${JSON.stringify({ event: "user", message: { role: "user", content: brief } })}\n`);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// A run from its exit code and its result event: a failure's words in its error, or in its response where it did not succeed. A run stopped after its result
|
|
335
|
+
// succeeded keeps it.
|
|
336
|
+
function runOf(code, result, stopped) {
|
|
337
|
+
const response = textOf(result?.response)?.trim() || undefined;
|
|
338
|
+
const status = textOf(result?.status);
|
|
339
|
+
const error = textOf(result?.error) ?? textOf(result?.error?.message) ?? (status !== "SUCCESS" ? response : undefined);
|
|
340
|
+
const denied = deniedOf(result?.denied_actions);
|
|
341
|
+
return {
|
|
342
|
+
code: stopped && status === "SUCCESS" ? 0 : code,
|
|
343
|
+
...(response === undefined ? {} : { response }),
|
|
344
|
+
...(status === undefined ? {} : { status }),
|
|
345
|
+
...(error === undefined || error.trim() === "" ? {} : { error: error.trim() }),
|
|
346
|
+
...(denied === undefined ? {} : { denied }),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
// What a closed run refused, by name where it gives one; undefined where it refused nothing.
|
|
350
|
+
function deniedOf(value) {
|
|
351
|
+
if (value === undefined || value === null || (Array.isArray(value) && value.length === 0)) {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
const items = Array.isArray(value) ? value : [value];
|
|
355
|
+
return items.flatMap((item) => {
|
|
356
|
+
const named = typeof item === "object" && item !== null ? item : undefined;
|
|
357
|
+
const name = textOf(item) ?? textOf(named?.action) ?? textOf(named?.name) ?? textOf(named?.tool);
|
|
358
|
+
return name === undefined ? [] : [name];
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function textOf(value) {
|
|
362
|
+
return typeof value === "string" ? value : undefined;
|
|
363
|
+
}
|
|
364
|
+
function eventOf(line) {
|
|
365
|
+
try {
|
|
366
|
+
const event = JSON.parse(line);
|
|
367
|
+
return typeof event === "object" && event !== null ? event : undefined;
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function writeOwner(root, owner) {
|
|
374
|
+
try {
|
|
375
|
+
writeFileSync(join(root, "owner.json"), JSON.stringify(owner));
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
// A folder taken away meanwhile: nothing to own.
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// One run's folder, taken away when its engine is gone, or when it names none and is an hour old; its agy stopped first.
|
|
382
|
+
async function sweepOne(root) {
|
|
383
|
+
try {
|
|
384
|
+
if (!isOwn(root)) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const owner = ownerOf(root);
|
|
388
|
+
if (owner === undefined ? Date.now() - statSync(root).mtimeMs < unownedAge : isAlive(owner.engine)) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (owner?.agy !== undefined && isAlive(owner.agy)) {
|
|
392
|
+
stopProcess(owner.agy);
|
|
393
|
+
}
|
|
394
|
+
await removeFolder(root);
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
// Gone already, or held: the next sweep tries again.
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function ownerOf(root) {
|
|
401
|
+
try {
|
|
402
|
+
const owner = JSON.parse(readFileSync(join(root, "owner.json"), "utf8"));
|
|
403
|
+
const pid = (value) => (typeof value === "number" && Number.isInteger(value) && value > 0 ? value : undefined);
|
|
404
|
+
const engine = pid(owner.engine);
|
|
405
|
+
const agy = pid(owner.agy);
|
|
406
|
+
return engine === undefined ? undefined : { engine, ...(agy === undefined ? {} : { agy }) };
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
return undefined;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
// A run's folder taken away in the background, never holding the answer nor throwing: what stays, as a home agy still holds, is the next sweep's.
|
|
413
|
+
function dropFolder(folder) {
|
|
414
|
+
void removeFolder(folder);
|
|
415
|
+
}
|
|
416
|
+
async function removeFolder(folder) {
|
|
417
|
+
try {
|
|
418
|
+
await rm(folder, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
|
|
419
|
+
}
|
|
420
|
+
catch {
|
|
421
|
+
// Held still: the next sweep takes it.
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// The chat's variables agy's runs never get: the engine's, and the chat's folder. More of Antigravity's own may join them.
|
|
425
|
+
const chatVariables = /^(RPG_|PWD$|OLDPWD$|INIT_CWD$)/i;
|
|
426
|
+
/**
|
|
427
|
+
* The environment of agy's runs: the chat's own, without what names the campaign, marked as a run of the engine's helper, and with `home` as its home, where
|
|
428
|
+
* agy makes its own folder; its login is in the system's keychain, and follows.
|
|
429
|
+
*/
|
|
430
|
+
function agyEnvironment(home) {
|
|
431
|
+
const name = process.platform === "win32" ? "USERPROFILE" : "HOME";
|
|
432
|
+
const environment = Object.entries(chatEnvironment(chatVariables)).filter(([variable]) => variable.toUpperCase() !== name);
|
|
433
|
+
return { ...Object.fromEntries(environment), RPG_HELPER: "1", [name]: home };
|
|
434
|
+
}
|
package/dist/helpers/chosen.d.ts
CHANGED
|
@@ -7,13 +7,17 @@ export declare const antigravityClient = "antigravity-client";
|
|
|
7
7
|
export declare const openCodeClient = "opencode";
|
|
8
8
|
/**
|
|
9
9
|
* The pictures of this computer, by the campaign's choice, which `choice` reads when a picture is asked: unset or chat, the chat `host` names, by its own
|
|
10
|
-
* means; codex
|
|
11
|
-
* in use; once it refused, it is not asked again while the
|
|
10
|
+
* means; codex or antigravity, a maker apart from the chat in use, or the chat's own in its own chat; elevenlabs, or the name of another image tool of the
|
|
11
|
+
* master's, from the brief. A maker apart, where it cannot or refuses, leaves the picture to the chat in use; once it refused, it is not asked again while the
|
|
12
|
+
* server lives, until the choice changes.
|
|
12
13
|
*/
|
|
13
|
-
export declare function hostPictures(host: () => string | undefined, choice?: () => string | undefined, codex?: PictureMaker, claude?: PictureMaker): PictureMaker;
|
|
14
|
+
export declare function hostPictures(host: () => string | undefined, choice?: () => string | undefined, codex?: PictureMaker, claude?: PictureMaker, antigravity?: PictureMaker): PictureMaker;
|
|
14
15
|
/** A chat that draws its pictures itself as SVG code (D-572), as OpenCode: from the SVG brief image gives it, handed back with image, svg; the engine starts nothing. */
|
|
15
16
|
export declare function chatDrawing(name: string): PictureMaker;
|
|
16
|
-
/** The writer of text of this computer for the chat `host` names (D-406): Codex first, then Claude; in OpenCode, OpenCode before them. */
|
|
17
|
-
export declare function hostWriter(host: () => string | undefined, codex?: TextWriter, claude?: TextWriter, openCode?: TextWriter): TextWriter;
|
|
18
|
-
/**
|
|
19
|
-
|
|
17
|
+
/** The writer of text of this computer for the chat `host` names (D-406): Codex first, then Claude; in OpenCode, OpenCode before them, in Antigravity, its agy (D-579 (1)). */
|
|
18
|
+
export declare function hostWriter(host: () => string | undefined, codex?: TextWriter, claude?: TextWriter, openCode?: TextWriter, antigravity?: TextWriter): TextWriter;
|
|
19
|
+
/**
|
|
20
|
+
* The importer of this computer for the chat `host` names (D-489 (1)): Codex in Codex, else Claude first, which Elena's probe measured, then Codex; in OpenCode,
|
|
21
|
+
* OpenCode before them, in Antigravity, its agy (D-579 (1)).
|
|
22
|
+
*/
|
|
23
|
+
export declare function hostReader(host: () => string | undefined, codex?: DocumentReader, claude?: DocumentReader, openCode?: DocumentReader, antigravity?: DocumentReader): DocumentReader;
|
package/dist/helpers/chosen.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { antigravityPainter, antigravityReader, antigravityWriter } from "./antigravity.js";
|
|
1
2
|
import { antigravityBrief, chatBrief, drawnBrief } from "./briefs.js";
|
|
2
3
|
import { claudePictures, claudeReader, claudeWriter } from "./claude.js";
|
|
3
4
|
import { codexPictures, codexReader, codexWriter } from "./codex.js";
|
|
@@ -10,11 +11,16 @@ export const antigravityClient = "antigravity-client";
|
|
|
10
11
|
export const openCodeClient = "opencode";
|
|
11
12
|
/**
|
|
12
13
|
* The pictures of this computer, by the campaign's choice, which `choice` reads when a picture is asked: unset or chat, the chat `host` names, by its own
|
|
13
|
-
* means; codex
|
|
14
|
-
* in use; once it refused, it is not asked again while the
|
|
14
|
+
* means; codex or antigravity, a maker apart from the chat in use, or the chat's own in its own chat; elevenlabs, or the name of another image tool of the
|
|
15
|
+
* master's, from the brief. A maker apart, where it cannot or refuses, leaves the picture to the chat in use; once it refused, it is not asked again while the
|
|
16
|
+
* server lives, until the choice changes.
|
|
15
17
|
*/
|
|
16
|
-
export function hostPictures(host, choice = () => undefined, codex = codexPictures(), claude = claudePictures()) {
|
|
17
|
-
|
|
18
|
+
export function hostPictures(host, choice = () => undefined, codex = codexPictures(), claude = claudePictures(), antigravity = antigravityPainter()) {
|
|
19
|
+
// The makers the campaign may choose apart from the chat in use, by their values: each with its name, its own chat, and its refusal remembered.
|
|
20
|
+
const makersApart = {
|
|
21
|
+
[codexChoice]: { maker: codex, name: "Codex", chat: codexClient },
|
|
22
|
+
[antigravityChoice]: { maker: antigravity, name: "Antigravity", chat: antigravityClient },
|
|
23
|
+
};
|
|
18
24
|
let lastChoice;
|
|
19
25
|
// The chat in use, by its own means: Claude's drawing in Claude Code, whose clients' names start with claude, and where no chat names itself.
|
|
20
26
|
const chat = () => {
|
|
@@ -24,25 +30,31 @@ export function hostPictures(host, choice = () => undefined, codex = codexPictur
|
|
|
24
30
|
}
|
|
25
31
|
return name === codexClient ? codex : name === antigravityClient ? antigravityPictures : chatDrawing(chatNames[name] ?? name);
|
|
26
32
|
};
|
|
27
|
-
// The maker the campaign chose, and
|
|
33
|
+
// The maker the campaign chose, and the maker apart it is, which leaves the picture to the chat in use where it cannot; in its own chat, the chat's own.
|
|
28
34
|
const chosen = () => {
|
|
29
35
|
const said = choice()?.trim();
|
|
30
|
-
// The player chose again:
|
|
36
|
+
// The player chose again: every maker apart is asked again.
|
|
31
37
|
if (said !== lastChoice) {
|
|
32
|
-
refused = undefined;
|
|
38
|
+
Object.values(makersApart).forEach((one) => (one.refused = undefined));
|
|
33
39
|
lastChoice = said;
|
|
34
40
|
}
|
|
35
41
|
const key = said?.toLowerCase();
|
|
36
42
|
if (key === undefined || key === "" || key === chatChoice) {
|
|
37
|
-
return { maker: chat()
|
|
43
|
+
return { maker: chat() };
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
const apart = makersApart[key];
|
|
46
|
+
if (apart !== undefined) {
|
|
47
|
+
return host() === apart.chat ? { maker: chat() } : { maker: apart.maker, apart };
|
|
41
48
|
}
|
|
42
|
-
return { maker: key === otherChoice ? unnamedTool : masterTool(key === elevenlabsChoice ? "ElevenLabs" : said ?? "")
|
|
49
|
+
return { maker: key === otherChoice ? unnamedTool : masterTool(key === elevenlabsChoice ? "ElevenLabs" : said ?? "") };
|
|
50
|
+
};
|
|
51
|
+
// A maker apart's record, as Codex is the chat's own in Codex too.
|
|
52
|
+
const apartOf = (maker) => Object.values(makersApart).find((one) => one.maker === maker);
|
|
53
|
+
// A maker's own answer, or its refusal remembered.
|
|
54
|
+
const readyOf = (maker, again) => {
|
|
55
|
+
const refused = apartOf(maker)?.refused;
|
|
56
|
+
return refused === undefined ? maker.ready(again) : { ready: false, why: refused };
|
|
43
57
|
};
|
|
44
|
-
// Codex's own answer, or its refusal remembered; in Codex, the chat's own.
|
|
45
|
-
const codexReady = (again) => (refused === undefined ? codex.ready(again) : { ready: false, why: refused });
|
|
46
58
|
const madeInstead = async (subject, instead) => {
|
|
47
59
|
const other = chat();
|
|
48
60
|
if (!other.ready().ready) {
|
|
@@ -55,46 +67,49 @@ export function hostPictures(host, choice = () => undefined, codex = codexPictur
|
|
|
55
67
|
const made = await other.make(subject);
|
|
56
68
|
return "refused" in made ? { refused: `${instead.why}; ${instead.by} made none either: ${made.refused}` } : { ...made, instead };
|
|
57
69
|
};
|
|
58
|
-
const fallbackOf = (said, refusedPicture = refused !== undefined) => {
|
|
70
|
+
const fallbackOf = (said, apart, refusedPicture = apart.refused !== undefined) => {
|
|
59
71
|
const other = chat().ready();
|
|
60
72
|
const by = other.ready ? other.maker : undefined;
|
|
61
|
-
return by === undefined
|
|
73
|
+
return by === undefined
|
|
74
|
+
? undefined
|
|
75
|
+
: { maker: apart.name, by, why: said.why, ...(said.fix === undefined ? {} : { fix: said.fix }), ...(refusedPicture ? { refused: true } : {}) };
|
|
62
76
|
};
|
|
63
77
|
return {
|
|
64
78
|
ready: (again) => {
|
|
65
|
-
const { maker,
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
const { maker, apart } = chosen();
|
|
80
|
+
const said = readyOf(maker, again);
|
|
81
|
+
if (apart === undefined) {
|
|
82
|
+
return said;
|
|
68
83
|
}
|
|
69
|
-
const
|
|
70
|
-
const instead = said.ready ? undefined : fallbackOf(said);
|
|
84
|
+
const instead = said.ready ? undefined : fallbackOf(said, apart);
|
|
71
85
|
return said.ready || instead === undefined ? said : { ready: true, maker: instead.by, ...(drawsItself(chat()) ? { draws: true } : {}), instead };
|
|
72
86
|
},
|
|
73
87
|
make: async (subject) => {
|
|
74
|
-
const { maker,
|
|
75
|
-
const said =
|
|
88
|
+
const { maker, apart } = chosen();
|
|
89
|
+
const said = readyOf(maker);
|
|
76
90
|
if (!said.ready) {
|
|
77
|
-
const instead =
|
|
91
|
+
const instead = apart === undefined ? undefined : fallbackOf(said, apart);
|
|
78
92
|
return instead === undefined ? { refused: said.why } : madeInstead(subject, instead);
|
|
79
93
|
}
|
|
80
94
|
const made = await maker.make(subject);
|
|
81
|
-
|
|
95
|
+
const remembered = apartOf(maker);
|
|
96
|
+
if (!("refused" in made) || remembered === undefined) {
|
|
82
97
|
return made;
|
|
83
98
|
}
|
|
84
|
-
// A refusal of this one picture, as the safety check's, leaves
|
|
99
|
+
// A refusal of this one picture, as the safety check's, leaves the maker asked for the next.
|
|
85
100
|
if (made.onlyThis !== true) {
|
|
86
|
-
refused = made.refused;
|
|
101
|
+
remembered.refused = made.refused;
|
|
87
102
|
}
|
|
88
|
-
const instead =
|
|
103
|
+
const instead = apart === undefined ? undefined : fallbackOf({ why: made.refused }, apart, true);
|
|
89
104
|
return instead === undefined ? made : madeInstead(subject, instead);
|
|
90
105
|
},
|
|
91
106
|
brief: (subject) => {
|
|
92
|
-
const { maker,
|
|
93
|
-
if (
|
|
107
|
+
const { maker, apart } = chosen();
|
|
108
|
+
if (apart === undefined) {
|
|
94
109
|
return maker.ready().ready ? maker.brief?.(subject) : undefined;
|
|
95
110
|
}
|
|
96
|
-
//
|
|
97
|
-
return
|
|
111
|
+
// The maker apart not ready: a chat that paints itself makes it in its place.
|
|
112
|
+
return readyOf(maker).ready ? undefined : chat().brief?.(subject);
|
|
98
113
|
},
|
|
99
114
|
};
|
|
100
115
|
}
|
|
@@ -102,6 +117,7 @@ export function hostPictures(host, choice = () => undefined, codex = codexPictur
|
|
|
102
117
|
// image tool of the master's.
|
|
103
118
|
const chatChoice = "chat";
|
|
104
119
|
const codexChoice = "codex";
|
|
120
|
+
const antigravityChoice = "antigravity";
|
|
105
121
|
const elevenlabsChoice = "elevenlabs";
|
|
106
122
|
const otherChoice = "other";
|
|
107
123
|
// Another image tool of the master's, which the player has not named yet: the master asks them which, from the same brief.
|
|
@@ -139,20 +155,31 @@ function masterTool(name) {
|
|
|
139
155
|
brief: chatBrief,
|
|
140
156
|
};
|
|
141
157
|
}
|
|
142
|
-
/** The writer of text of this computer for the chat `host` names (D-406): Codex first, then Claude; in OpenCode, OpenCode before them. */
|
|
143
|
-
export function hostWriter(host, codex = codexWriter(), claude = claudeWriter(), openCode = openCodeWriter()) {
|
|
144
|
-
const writers = () =>
|
|
158
|
+
/** The writer of text of this computer for the chat `host` names (D-406): Codex first, then Claude; in OpenCode, OpenCode before them, in Antigravity, its agy (D-579 (1)). */
|
|
159
|
+
export function hostWriter(host, codex = codexWriter(), claude = claudeWriter(), openCode = openCodeWriter(), antigravity = antigravityWriter()) {
|
|
160
|
+
const writers = () => {
|
|
161
|
+
const chat = host();
|
|
162
|
+
return chat === codexClient ? [codex] : chat === openCodeClient ? [openCode, codex, claude] : chat === antigravityClient ? [antigravity, codex, claude] : [codex, claude];
|
|
163
|
+
};
|
|
145
164
|
return {
|
|
146
165
|
ready: () => writers().some((writer) => writer.ready()),
|
|
147
166
|
write: (brief) => (writers().find((writer) => writer.ready()) ?? codex).write(brief),
|
|
148
167
|
};
|
|
149
168
|
}
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
169
|
+
/**
|
|
170
|
+
* The importer of this computer for the chat `host` names (D-489 (1)): Codex in Codex, else Claude first, which Elena's probe measured, then Codex; in OpenCode,
|
|
171
|
+
* OpenCode before them, in Antigravity, its agy (D-579 (1)).
|
|
172
|
+
*/
|
|
173
|
+
export function hostReader(host, codex = codexReader(), claude = claudeReader(), openCode = openCodeReader(), antigravity = antigravityReader()) {
|
|
174
|
+
const readers = () => {
|
|
175
|
+
const chat = host();
|
|
176
|
+
return chat === codexClient ? [codex] : chat === openCodeClient ? [openCode, claude, codex] : chat === antigravityClient ? [antigravity, claude, codex] : [claude, codex];
|
|
177
|
+
};
|
|
153
178
|
return {
|
|
154
179
|
ready: () => readers().some((reader) => reader.ready()),
|
|
155
180
|
program: () => readers().find((reader) => reader.ready())?.program?.(),
|
|
181
|
+
model: () => readers().find((reader) => reader.ready())?.model?.(),
|
|
182
|
+
clean: () => [codex, claude, openCode, antigravity].forEach((reader) => reader.clean?.()),
|
|
156
183
|
read: (folder, brief, writable, signal) => (readers().find((reader) => reader.ready()) ?? claude).read(folder, brief, writable, signal),
|
|
157
184
|
};
|
|
158
185
|
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { type AgySettings, antigravityPainter, antigravityReader, antigravitySays, antigravityWriter, painterSettings, playerModel, readerSettings, sealedSettings } from "./antigravity.ts";
|
|
1
2
|
export { antigravityBrief, chatBrief, drawnBrief, paintedBrief, svgBrief } from "./briefs.ts";
|
|
2
3
|
export { antigravityClient, chatDrawing, codexClient, hostPictures, hostReader, hostWriter, openCodeClient } from "./chosen.ts";
|
|
3
4
|
export { claudeSays } from "./claude.ts";
|