@kenkaiiii/ggcoder 5.95.1 → 5.95.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenkaiiii/ggcoder",
3
- "version": "5.95.1",
3
+ "version": "5.95.3",
4
4
  "type": "module",
5
5
  "description": "The engine and CLI behind the GG Coder desktop app: a lean coding agent for Claude, ChatGPT, Grok, Kimi, 12 providers and local models.",
6
6
  "author": "Ken Kai",
@@ -131,9 +131,9 @@
131
131
  "typescript-language-server": "^5.3.0",
132
132
  "wrap-ansi": "^10.0.0",
133
133
  "zod": "^4.4.3",
134
- "@kenkaiiii/gg-agent": "5.95.1",
135
- "@kenkaiiii/gg-ai": "5.95.1",
136
- "@kenkaiiii/gg-core": "5.95.1"
134
+ "@kenkaiiii/gg-agent": "5.95.3",
135
+ "@kenkaiiii/gg-ai": "5.95.3",
136
+ "@kenkaiiii/gg-core": "5.95.3"
137
137
  },
138
138
  "optionalDependencies": {
139
139
  "@huggingface/transformers": "4.2.0",
@@ -1,40 +0,0 @@
1
- /** The live GG World server. GG_WORLD_URL overrides it. */
2
- export declare const DEFAULT_WORLD_URL = "https://gg-world.buzzbeamaustralia.workers.dev";
3
- /** The retired GG Royale server. Links made with it belong to the live World
4
- * server (same database), so they are never re-registered. */
5
- export declare const LEGACY_ROYALE_URL = "https://gg-royale.buzzbeamaustralia.workers.dev";
6
- export interface RoyaleFile {
7
- serverUrl?: string;
8
- playerId: string;
9
- deviceToken: string;
10
- linkedAt: number;
11
- }
12
- /**
13
- * A World server reply, passed through for the app to read: `status` is the
14
- * HTTP status (409 stale ver, 400 validation with `body.error`, ...), or 0
15
- * when the server couldn't be reached. Never throws.
16
- */
17
- export interface WorldResult {
18
- status: number;
19
- body: unknown;
20
- }
21
- export interface WorldLinkOptions {
22
- agentDir: string;
23
- version: string;
24
- env?: NodeJS.ProcessEnv;
25
- fetchImpl?: typeof fetch;
26
- now?: () => number;
27
- }
28
- export interface WorldLink {
29
- /** GET /api/world/profile. Signs up on first use. */
30
- worldGet: () => Promise<WorldResult>;
31
- /** PUT /api/world/profile with `{ ver, patch }`. */
32
- worldPut: (ver: number, patch: unknown) => Promise<WorldResult>;
33
- /** DELETE /api/world/me (the online save only). */
34
- worldDelete: () => Promise<WorldResult>;
35
- /** POST /api/world/live: a one-time live-world ticket `{ world, ticket, url }`. */
36
- worldLive: () => Promise<WorldResult>;
37
- /** DELETE /api/world/account; on success the local link file is removed. */
38
- accountDelete: () => Promise<WorldResult>;
39
- }
40
- export declare function createWorldLink(opts: WorldLinkOptions): WorldLink;
@@ -1,149 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { log } from "../core/logger.js";
4
- // ── GG World device link ────────────────────────────────────────────────
5
- // One device link per install, used only for GG World online save and the
6
- // live world. It lives in ~/.gg/royale.json (the name is from GG Royale, now
7
- // closed; the file and its format are unchanged so existing players keep
8
- // their account). The device token is only ever sent to the server it was
9
- // minted for.
10
- /** The live GG World server. GG_WORLD_URL overrides it. */
11
- export const DEFAULT_WORLD_URL = "https://gg-world.buzzbeamaustralia.workers.dev";
12
- /** The retired GG Royale server. Links made with it belong to the live World
13
- * server (same database), so they are never re-registered. */
14
- export const LEGACY_ROYALE_URL = "https://gg-royale.buzzbeamaustralia.workers.dev";
15
- const WORLD_TIMEOUT_MS = 8_000;
16
- const REGISTER_TIMEOUT_MS = 10_000;
17
- function stripSlashes(url) {
18
- return url.replace(/\/+$/, "");
19
- }
20
- /** The server a saved link belongs to: missing or the old Royale URL = live World. */
21
- function linkServer(file) {
22
- const url = stripSlashes(file.serverUrl ?? DEFAULT_WORLD_URL);
23
- return url === LEGACY_ROYALE_URL ? DEFAULT_WORLD_URL : url;
24
- }
25
- function isRoyaleFile(v) {
26
- if (typeof v !== "object" || v === null)
27
- return false;
28
- const o = v;
29
- return (typeof o.playerId === "string" &&
30
- typeof o.deviceToken === "string" &&
31
- o.deviceToken.length > 0 &&
32
- typeof o.linkedAt === "number" &&
33
- (o.serverUrl === undefined || typeof o.serverUrl === "string"));
34
- }
35
- export function createWorldLink(opts) {
36
- const filePath = path.join(opts.agentDir, "royale.json");
37
- const env = opts.env ?? process.env;
38
- const doFetch = opts.fetchImpl ?? fetch;
39
- const now = opts.now ?? Date.now;
40
- function base() {
41
- const fromEnv = env.GG_WORLD_URL;
42
- return stripSlashes(fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_WORLD_URL);
43
- }
44
- async function read() {
45
- try {
46
- const parsed = JSON.parse(await fs.readFile(filePath, "utf8"));
47
- return isRoyaleFile(parsed) ? parsed : null;
48
- }
49
- catch {
50
- return null;
51
- }
52
- }
53
- /** The saved link, only if it belongs to the server we're talking to. */
54
- async function link() {
55
- const file = await read();
56
- return file && linkServer(file) === base() ? file : null;
57
- }
58
- async function write(file) {
59
- await fs.mkdir(opts.agentDir, { recursive: true });
60
- // The device token is private from its first byte: write a 0600 temp
61
- // file and rename it into place.
62
- const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
63
- try {
64
- await fs.writeFile(tmp, JSON.stringify(file, null, 2), {
65
- encoding: "utf8",
66
- flag: "wx",
67
- mode: 0o600,
68
- });
69
- await fs.rename(tmp, filePath);
70
- }
71
- finally {
72
- await fs.rm(tmp, { force: true }).catch(() => { });
73
- }
74
- await fs.chmod(filePath, 0o600).catch(() => { });
75
- }
76
- async function register(server) {
77
- const res = await doFetch(`${server}/api/world/device/register`, {
78
- method: "POST",
79
- headers: { "content-type": "application/json" },
80
- body: JSON.stringify({ client: "gg-coder", version: opts.version }),
81
- signal: AbortSignal.timeout(REGISTER_TIMEOUT_MS),
82
- });
83
- if (!res.ok)
84
- throw new Error(`World sign-up failed (HTTP ${res.status}).`);
85
- const r = (await res.json());
86
- if (typeof r?.playerId !== "string" ||
87
- typeof r.deviceToken !== "string" ||
88
- r.deviceToken.length === 0) {
89
- throw new Error("The World server sent an unexpected sign-up response.");
90
- }
91
- const file = {
92
- playerId: r.playerId,
93
- deviceToken: r.deviceToken,
94
- linkedAt: now(),
95
- serverUrl: server,
96
- };
97
- await write(file);
98
- return file;
99
- }
100
- async function world(method, route, body) {
101
- const server = base();
102
- try {
103
- const linked = await link();
104
- // Nothing to delete without a link: don't sign up just to delete.
105
- if (!linked && method === "DELETE")
106
- return { status: 200, body: { deleted: true } };
107
- const file = linked ?? (await register(server));
108
- const res = await doFetch(`${server}${route}`, {
109
- method,
110
- headers: {
111
- authorization: `Bearer ${file.deviceToken}`,
112
- ...(body === undefined ? {} : { "content-type": "application/json" }),
113
- },
114
- body: body === undefined ? undefined : JSON.stringify(body),
115
- signal: AbortSignal.timeout(WORLD_TIMEOUT_MS),
116
- });
117
- let parsed = null;
118
- try {
119
- parsed = await res.json();
120
- }
121
- catch {
122
- parsed = null;
123
- }
124
- return { status: res.status, body: parsed };
125
- }
126
- catch (err) {
127
- log("DEBUG", "world", "world request failed", {
128
- message: err instanceof Error ? err.message : String(err),
129
- });
130
- return { status: 0, body: { error: "Couldn't reach the server." } };
131
- }
132
- }
133
- async function accountDelete() {
134
- const result = await world("DELETE", "/api/world/account");
135
- // 404: the server no longer knows this device, so the account is gone too.
136
- if ((result.status >= 200 && result.status < 300) || result.status === 404) {
137
- await fs.rm(filePath, { force: true }).catch(() => { });
138
- }
139
- return result;
140
- }
141
- return {
142
- worldGet: () => world("GET", "/api/world/profile"),
143
- worldPut: (ver, patch) => world("PUT", "/api/world/profile", { ver, patch }),
144
- worldDelete: () => world("DELETE", "/api/world/me"),
145
- worldLive: () => world("POST", "/api/world/live", {}),
146
- accountDelete,
147
- };
148
- }
149
- //# sourceMappingURL=royale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"royale.js","sourceRoot":"","sources":["../../src/app-sidecar/royale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE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