@maka/maka-cli 5.69.0 → 5.71.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/bundle/typescript/package.json +13 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/backlog.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/backlog.js +3 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/backlog.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/call.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/call.js +4 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/call.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/cast.js +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/cast.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js +24 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.d.ts +18 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js +20 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/grapple.js +12 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/grapple.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/hack.d.ts +11 -4
- package/bundle/typescript/src/commands/game/sideQuest/commands/hack.js +11 -4
- package/bundle/typescript/src/commands/game/sideQuest/commands/hack.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/pan.js +14 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/pan.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/roles.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/roles.js +3 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/roles.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/room-factory.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/room-factory.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-chunks.d.ts +4 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-chunks.js +21 -2
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-chunks.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/item.d.ts +36 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js +79 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js +76 -62
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.d.ts +84 -12
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js +94 -28
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/room.d.ts +7 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js +23 -3
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/room-seed.d.ts +5 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog-dump.d.ts +10 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog-dump.js +91 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog-dump.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog.d.ts +41 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog.js +63 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/backlog.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/combat-exchange.d.ts +7 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/combat-exchange.js +19 -5
- package/bundle/typescript/src/commands/game/sideQuest/utilities/combat-exchange.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/crash-evidence.d.ts +53 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/crash-evidence.js +106 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/crash-evidence.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/detach-args.d.ts +66 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/detach-args.js +75 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/detach-args.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/utilities/outdoors.d.ts +25 -7
- package/bundle/typescript/src/commands/game/sideQuest/utilities/outdoors.js +27 -7
- package/bundle/typescript/src/commands/game/sideQuest/utilities/outdoors.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/planes.js +9 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/planes.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest-backlog.sub.cmd.js +16 -0
- package/bundle/typescript/src/commands/game/sideQuest-backlog.sub.cmd.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.d.ts +33 -0
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +46 -6
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
- package/bundle/typescript/src/commands/login.js +38 -20
- package/bundle/typescript/src/commands/login.js.map +1 -1
- package/bundle/typescript/src/commands/logout.js +36 -17
- package/bundle/typescript/src/commands/logout.js.map +1 -1
- package/bundle/typescript/src/commands/register.js +24 -10
- package/bundle/typescript/src/commands/register.js.map +1 -1
- package/bundle/typescript/src/tools/ai/ai.class.d.ts +71 -0
- package/bundle/typescript/src/tools/ai/ai.class.js +202 -7
- package/bundle/typescript/src/tools/ai/ai.class.js.map +1 -1
- package/bundle/typescript/src/tools/https/connection-error.d.ts +79 -0
- package/bundle/typescript/src/tools/https/connection-error.js +134 -0
- package/bundle/typescript/src/tools/https/connection-error.js.map +1 -0
- package/bundle/typescript/src/tools/https/https.class.d.ts +1 -1
- package/bundle/typescript/src/tools/https/https.class.js +64 -14
- package/bundle/typescript/src/tools/https/https.class.js.map +1 -1
- package/bundle/typescript/src/tools/https/https.interface.d.ts +8 -0
- package/bundle/typescript/src/tools/https/maka-host.d.ts +43 -0
- package/bundle/typescript/src/tools/https/maka-host.js +8 -0
- package/bundle/typescript/src/tools/https/maka-host.js.map +1 -0
- package/package.json +13 -2
|
@@ -84,6 +84,77 @@ export declare class AI {
|
|
|
84
84
|
* generation entry points; the server's token clamp is the belt.
|
|
85
85
|
*/
|
|
86
86
|
static canGenerate(): boolean;
|
|
87
|
+
/** How much of an unparseable body to quote back. Enough to
|
|
88
|
+
* recognize a gateway page or a captive portal, short enough that an
|
|
89
|
+
* error line stays an error line -- a 50 KB HTML dump in the session
|
|
90
|
+
* log is not a diagnostic. */
|
|
91
|
+
private static readonly BODY_SNIFF;
|
|
92
|
+
/**
|
|
93
|
+
* The message for a reply that was not JSON at all. There is no
|
|
94
|
+
* provider envelope to read in this case, so this says the two things
|
|
95
|
+
* that are actually known: WHO was called and WHAT the transport
|
|
96
|
+
* answered.
|
|
97
|
+
*
|
|
98
|
+
* A 502/503/504 in front of a JSON API is a gateway, not the API --
|
|
99
|
+
* the service is down or mid-deploy and the request was never seen.
|
|
100
|
+
* It gets its own wording because the alternative is a player reading
|
|
101
|
+
* "the AI refused" and going to check a login that is perfectly fine.
|
|
102
|
+
*/
|
|
103
|
+
private static describeUnparseable;
|
|
104
|
+
/**
|
|
105
|
+
* The message for a request that FAILED at the HTTP level while
|
|
106
|
+
* returning perfectly well-formed JSON that simply says nothing about
|
|
107
|
+
* why (4MADSCbQMT2gzcGFW).
|
|
108
|
+
*
|
|
109
|
+
* This used to fall all the way through to the content check and come
|
|
110
|
+
* out as "No content returned from <provider>", which describes a
|
|
111
|
+
* malformed SUCCESS -- the wrong diagnosis for a request that never
|
|
112
|
+
* succeeded, with HTTP 503 sitting unread in the response the whole
|
|
113
|
+
* time. The status was only ever consulted on the relay path, and
|
|
114
|
+
* only when the body happened to carry a `message`.
|
|
115
|
+
*
|
|
116
|
+
* Same wording as the non-JSON path above, deliberately: whether the
|
|
117
|
+
* failure arrived as an nginx HTML page or as a tidy `{"detail": ...}`
|
|
118
|
+
* is not the player's problem and must not change the diagnosis.
|
|
119
|
+
*/
|
|
120
|
+
private static describeHttpFailure;
|
|
121
|
+
private static providerLabel;
|
|
122
|
+
/**
|
|
123
|
+
* A 502/503/504 in front of a JSON API is a GATEWAY, not the API --
|
|
124
|
+
* the service is down or mid-deploy and the request was never seen.
|
|
125
|
+
* It gets its own wording because the alternative is a player reading
|
|
126
|
+
* "the AI refused" and going to check a login that is perfectly fine.
|
|
127
|
+
*/
|
|
128
|
+
private static gatewayNote;
|
|
129
|
+
private static sniff;
|
|
130
|
+
/**
|
|
131
|
+
* What to DO about a relay failure: stop asking, and/or say it out
|
|
132
|
+
* loud once. The contract's three-line mapping, with `retryable`
|
|
133
|
+
* checked FIRST so an unrecognised future kind lands in the right
|
|
134
|
+
* bucket instead of an unknown one.
|
|
135
|
+
*
|
|
136
|
+
* `upstream_billing` stops the relay as well as raising the notice,
|
|
137
|
+
* which the contract does not require and this client does. The
|
|
138
|
+
* reason is local: game.ts's notice text states that NPC voices are
|
|
139
|
+
* OFFLINE. Firing it while continuing to call the relay on every line
|
|
140
|
+
* would make the sentence a lie -- so here, notifying and stopping
|
|
141
|
+
* are one decision. Credit exhausted at the provider does not refill
|
|
142
|
+
* itself mid-session either.
|
|
143
|
+
*
|
|
144
|
+
* With no envelope, every answer is exactly what it was before: the
|
|
145
|
+
* relay's 401/403 stop it, nothing else does.
|
|
146
|
+
*/
|
|
147
|
+
private static relayVerdict;
|
|
148
|
+
/**
|
|
149
|
+
* What a failed reply actually SAID, if anything -- the one thing
|
|
150
|
+
* always worth more than a status number.
|
|
151
|
+
*
|
|
152
|
+
* Providers disagree on where it lives: Anthropic and OpenAI nest it
|
|
153
|
+
* under `error`, the maka-cli.com relay puts it at the top level.
|
|
154
|
+
* Only the nested form was ever read on the direct providers, so a
|
|
155
|
+
* bare top-level {message} was lost along with the status.
|
|
156
|
+
*/
|
|
157
|
+
private static statedError;
|
|
87
158
|
/**
|
|
88
159
|
* Sends `prompt` to whichever provider is configured and returns the
|
|
89
160
|
* completion text. Throws if no provider is configured, the request
|
|
@@ -223,6 +223,148 @@ export class AI {
|
|
|
223
223
|
return true;
|
|
224
224
|
return this.serverAccess === 'full';
|
|
225
225
|
}
|
|
226
|
+
/** How much of an unparseable body to quote back. Enough to
|
|
227
|
+
* recognize a gateway page or a captive portal, short enough that an
|
|
228
|
+
* error line stays an error line -- a 50 KB HTML dump in the session
|
|
229
|
+
* log is not a diagnostic. */
|
|
230
|
+
static BODY_SNIFF = 140;
|
|
231
|
+
/**
|
|
232
|
+
* The message for a reply that was not JSON at all. There is no
|
|
233
|
+
* provider envelope to read in this case, so this says the two things
|
|
234
|
+
* that are actually known: WHO was called and WHAT the transport
|
|
235
|
+
* answered.
|
|
236
|
+
*
|
|
237
|
+
* A 502/503/504 in front of a JSON API is a gateway, not the API --
|
|
238
|
+
* the service is down or mid-deploy and the request was never seen.
|
|
239
|
+
* It gets its own wording because the alternative is a player reading
|
|
240
|
+
* "the AI refused" and going to check a login that is perfectly fine.
|
|
241
|
+
*/
|
|
242
|
+
static describeUnparseable(provider, statusCode, body) {
|
|
243
|
+
return this.gatewayNote(provider, statusCode)
|
|
244
|
+
?? `${this.providerLabel(provider)} answered HTTP ${statusCode} with a body that is not JSON: `
|
|
245
|
+
+ `${this.sniff(body)}`;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The message for a request that FAILED at the HTTP level while
|
|
249
|
+
* returning perfectly well-formed JSON that simply says nothing about
|
|
250
|
+
* why (4MADSCbQMT2gzcGFW).
|
|
251
|
+
*
|
|
252
|
+
* This used to fall all the way through to the content check and come
|
|
253
|
+
* out as "No content returned from <provider>", which describes a
|
|
254
|
+
* malformed SUCCESS -- the wrong diagnosis for a request that never
|
|
255
|
+
* succeeded, with HTTP 503 sitting unread in the response the whole
|
|
256
|
+
* time. The status was only ever consulted on the relay path, and
|
|
257
|
+
* only when the body happened to carry a `message`.
|
|
258
|
+
*
|
|
259
|
+
* Same wording as the non-JSON path above, deliberately: whether the
|
|
260
|
+
* failure arrived as an nginx HTML page or as a tidy `{"detail": ...}`
|
|
261
|
+
* is not the player's problem and must not change the diagnosis.
|
|
262
|
+
*/
|
|
263
|
+
static describeHttpFailure(provider, statusCode, body) {
|
|
264
|
+
return this.gatewayNote(provider, statusCode)
|
|
265
|
+
?? `${this.providerLabel(provider)} answered HTTP ${statusCode} with no error to read: `
|
|
266
|
+
+ `${this.sniff(body)}`;
|
|
267
|
+
}
|
|
268
|
+
static providerLabel(provider) {
|
|
269
|
+
return provider === 'server' ? 'The maka-cli.com AI relay' : `The ${provider} API`;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* A 502/503/504 in front of a JSON API is a GATEWAY, not the API --
|
|
273
|
+
* the service is down or mid-deploy and the request was never seen.
|
|
274
|
+
* It gets its own wording because the alternative is a player reading
|
|
275
|
+
* "the AI refused" and going to check a login that is perfectly fine.
|
|
276
|
+
*/
|
|
277
|
+
static gatewayNote(provider, statusCode) {
|
|
278
|
+
if (statusCode !== 502 && statusCode !== 503 && statusCode !== 504)
|
|
279
|
+
return undefined;
|
|
280
|
+
return `${this.providerLabel(provider)} is unreachable right now (HTTP ${statusCode}) -- `
|
|
281
|
+
+ `the service is down or mid-deploy. `
|
|
282
|
+
+ `Nothing is wrong with your account or your request; try again shortly.`;
|
|
283
|
+
}
|
|
284
|
+
static sniff(body) {
|
|
285
|
+
const text = (body ?? '').replace(/\s+/g, ' ').trim();
|
|
286
|
+
// `""` is a body that parses fine and says nothing. Quoting it back
|
|
287
|
+
// yields `""""`, which reads as a mangled message rather than an
|
|
288
|
+
// absent one -- and "the server said nothing" is the actual fact.
|
|
289
|
+
const meaningful = text === '""' ? '' : text.slice(0, this.BODY_SNIFF);
|
|
290
|
+
return meaningful.length > 0 ? `"${meaningful}"` : '(empty)';
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* What to DO about a relay failure: stop asking, and/or say it out
|
|
294
|
+
* loud once. The contract's three-line mapping, with `retryable`
|
|
295
|
+
* checked FIRST so an unrecognised future kind lands in the right
|
|
296
|
+
* bucket instead of an unknown one.
|
|
297
|
+
*
|
|
298
|
+
* `upstream_billing` stops the relay as well as raising the notice,
|
|
299
|
+
* which the contract does not require and this client does. The
|
|
300
|
+
* reason is local: game.ts's notice text states that NPC voices are
|
|
301
|
+
* OFFLINE. Firing it while continuing to call the relay on every line
|
|
302
|
+
* would make the sentence a lie -- so here, notifying and stopping
|
|
303
|
+
* are one decision. Credit exhausted at the provider does not refill
|
|
304
|
+
* itself mid-session either.
|
|
305
|
+
*
|
|
306
|
+
* With no envelope, every answer is exactly what it was before: the
|
|
307
|
+
* relay's 401/403 stop it, nothing else does.
|
|
308
|
+
*/
|
|
309
|
+
static relayVerdict(provider, parsed, statusCode) {
|
|
310
|
+
const none = { envelope: false, stop: false, notify: false };
|
|
311
|
+
// The envelope belongs to maka-cli.com. A direct provider body that
|
|
312
|
+
// happened to carry `kind` must never steer the relay switch.
|
|
313
|
+
if (provider !== 'server')
|
|
314
|
+
return none;
|
|
315
|
+
if (typeof parsed !== 'object' || parsed === null || !('kind' in parsed)) {
|
|
316
|
+
const terminal = statusCode === 401 || statusCode === 403;
|
|
317
|
+
return { envelope: false, stop: terminal, notify: terminal };
|
|
318
|
+
}
|
|
319
|
+
const body = parsed;
|
|
320
|
+
// AUTHORITATIVE, and never re-derived from the status: a kind that
|
|
321
|
+
// says retryable is transient even on a status that looks fatal.
|
|
322
|
+
if (body.retryable === true)
|
|
323
|
+
return { envelope: true, stop: false, notify: false };
|
|
324
|
+
const kind = typeof body.kind === 'string' ? body.kind : '';
|
|
325
|
+
// `status` is mirrored into the body for clients whose transport
|
|
326
|
+
// loses it -- ours has a known bug that does exactly that, so
|
|
327
|
+
// prefer the body's own number when it gives one.
|
|
328
|
+
const status = typeof body.status === 'number' ? body.status : statusCode;
|
|
329
|
+
// The contract's own mapping, in its own order: billing first
|
|
330
|
+
// (whose account it is changes what the player is told), then the
|
|
331
|
+
// login statuses. NOT a list of terminal KIND NAMES -- a mutation
|
|
332
|
+
// proved such a set could never fire on its own, because every kind
|
|
333
|
+
// in the contract's terminal table carries 401 or 403 anyway. A
|
|
334
|
+
// check that cannot fail is not a safeguard, it is decoration that
|
|
335
|
+
// reads like one.
|
|
336
|
+
const fatal = kind === 'upstream_billing' || status === 401 || status === 403;
|
|
337
|
+
return { envelope: true, stop: fatal, notify: fatal };
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* What a failed reply actually SAID, if anything -- the one thing
|
|
341
|
+
* always worth more than a status number.
|
|
342
|
+
*
|
|
343
|
+
* Providers disagree on where it lives: Anthropic and OpenAI nest it
|
|
344
|
+
* under `error`, the maka-cli.com relay puts it at the top level.
|
|
345
|
+
* Only the nested form was ever read on the direct providers, so a
|
|
346
|
+
* bare top-level {message} was lost along with the status.
|
|
347
|
+
*/
|
|
348
|
+
static statedError(parsed) {
|
|
349
|
+
// A BARE JSON STRING IS A REAL BODY. maka:rest answers its own
|
|
350
|
+
// framework failures with a quoted string and nothing else --
|
|
351
|
+
// `"Unauthorized"` (401), `"Forbidden"` (403), `"Too many requests"`
|
|
352
|
+
// (429), `"Server Error"` (500). JSON.parse succeeds and hands back
|
|
353
|
+
// a string, so every `parsed?.x` read below it is undefined. The
|
|
354
|
+
// 429 can fire today: the relay limits 20 points per 10s per IP.
|
|
355
|
+
if (typeof parsed === 'string') {
|
|
356
|
+
const bare = parsed.trim();
|
|
357
|
+
return bare.length > 0 ? bare : undefined;
|
|
358
|
+
}
|
|
359
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
360
|
+
return undefined;
|
|
361
|
+
const shape = parsed;
|
|
362
|
+
const raw = typeof shape.error?.message === 'string' ? shape.error.message
|
|
363
|
+
: typeof shape.message === 'string' ? shape.message
|
|
364
|
+
: undefined;
|
|
365
|
+
const trimmed = raw?.trim();
|
|
366
|
+
return trimmed !== undefined && trimmed.length > 0 ? trimmed : undefined;
|
|
367
|
+
}
|
|
226
368
|
/**
|
|
227
369
|
* Sends `prompt` to whichever provider is configured and returns the
|
|
228
370
|
* completion text. Throws if no provider is configured, the request
|
|
@@ -249,23 +391,76 @@ export class AI {
|
|
|
249
391
|
: config.provider === 'deepseek'
|
|
250
392
|
? await HTTPS.askDeepSeek({ prompt, apiKey: config.apiKey, model: config.model, maxTokens: opts?.maxTokens })
|
|
251
393
|
: await HTTPS.askMakaServer({ prompt, authToken: config.apiKey, model: config.model, maxTokens: opts?.maxTokens });
|
|
252
|
-
|
|
394
|
+
// A BODY THAT IS NOT JSON IS AN HTTP PROBLEM, NOT A PARSE PROBLEM.
|
|
395
|
+
// This parse used to run bare, AHEAD of the statusCode guard below
|
|
396
|
+
// -- so that guard only ever protected JSON-shaped failures. When
|
|
397
|
+
// maka-cli.com went mid-deploy on 2026-08-29, nginx answered with a
|
|
398
|
+
// 502 HTML page, JSON.parse threw first, and the SyntaxError rode
|
|
399
|
+
// out of a fire-and-forget NPC reaction into ui.ts's fatal handler
|
|
400
|
+
// and killed the session twice.
|
|
401
|
+
//
|
|
402
|
+
// Deliberately in FRONT of the branches below rather than replacing
|
|
403
|
+
// them: every provider reports its own 4xx as a JSON error envelope
|
|
404
|
+
// (Anthropic's spent-credits 400, the relay's expired-login 401),
|
|
405
|
+
// and those must keep routing to onProviderRefusal exactly as they
|
|
406
|
+
// do. Only a body with no envelope to read at all lands here, and
|
|
407
|
+
// then the status is the one thing left that can explain it.
|
|
408
|
+
// Untyped on purpose: JSON.parse hands back `any`, and every read
|
|
409
|
+
// below is a defensive `?.` against a shape we do not control.
|
|
410
|
+
let parsedRaw;
|
|
411
|
+
try {
|
|
412
|
+
parsedRaw = JSON.parse(result.data);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
throw new Error(this.describeUnparseable(config.provider, result.statusCode, result.data));
|
|
416
|
+
}
|
|
253
417
|
// The relay wraps Anthropic's verbatim response in the REST API's
|
|
254
418
|
// {data} envelope; unwrap so the shared parsing below sees the same
|
|
255
419
|
// shape a direct Anthropic call returns.
|
|
256
420
|
const parsed = config.provider === 'server' ? (parsedRaw?.data ?? parsedRaw) : parsedRaw;
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
421
|
+
// THE TRANSPORT FAILED -- ask the body for content only once HTTP
|
|
422
|
+
// has agreed the exchange worked (4MADSCbQMT2gzcGFW).
|
|
423
|
+
//
|
|
424
|
+
// This was the relay's branch alone, and only fired when the body
|
|
425
|
+
// happened to carry a `message`. Everything else with a 4xx/5xx --
|
|
426
|
+
// a direct provider's 503, a body of `{}`, the REST framework's
|
|
427
|
+
// bare `"Too many requests"` string -- sailed past an unread status
|
|
428
|
+
// code and came out the far end as "No content returned from
|
|
429
|
+
// <provider>", which describes a malformed SUCCESS. Wrong
|
|
430
|
+
// diagnosis, and it sent at least one investigation looking at the
|
|
431
|
+
// wrong layer.
|
|
432
|
+
//
|
|
433
|
+
// What the body SAID still outranks the status: the status-naming
|
|
434
|
+
// message is the fallback for when nothing was said, never a
|
|
435
|
+
// replacement for a real diagnosis.
|
|
436
|
+
if (result.statusCode >= 400) {
|
|
437
|
+
const stated = this.statedError(parsed) ?? this.statedError(parsedRaw);
|
|
438
|
+
const message = stated ?? this.describeHttpFailure(config.provider, result.statusCode, result.data);
|
|
439
|
+
// WHEN IS THE RELAY FINISHED? Read the contract's envelope if it
|
|
440
|
+
// sent one, and fall back to 401/403 if it did not. Deliberately
|
|
441
|
+
// NOT extended to 5xx by status: a mid-deploy 502 is not an
|
|
442
|
+
// expired login, and treating it as one leaves every NPC canned
|
|
443
|
+
// until the player restarts.
|
|
444
|
+
const verdict = this.relayVerdict(config.provider, parsed, result.statusCode);
|
|
445
|
+
if (verdict.stop) {
|
|
263
446
|
AI.serverAccess = 'denied';
|
|
447
|
+
}
|
|
448
|
+
if (verdict.notify) {
|
|
264
449
|
try {
|
|
265
450
|
this.onProviderRefusal?.(message);
|
|
266
451
|
}
|
|
267
452
|
catch { /* notice must never mask the throw */ }
|
|
268
453
|
}
|
|
454
|
+
else if (!verdict.envelope && stated !== undefined && this.REFUSAL_RE.test(stated)) {
|
|
455
|
+
// Out-of-money wording, wherever the provider chose to put it.
|
|
456
|
+
// REFUSAL_RE used to run against `error.message` only, so the
|
|
457
|
+
// same spent-credits sentence got the one loud notice when
|
|
458
|
+
// nested and silence when top-level.
|
|
459
|
+
try {
|
|
460
|
+
this.onProviderRefusal?.(stated);
|
|
461
|
+
}
|
|
462
|
+
catch { /* notice must never mask the throw */ }
|
|
463
|
+
}
|
|
269
464
|
throw new Error(message);
|
|
270
465
|
}
|
|
271
466
|
if (parsed?.error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.class.js","sourceRoot":"","sources":["../../../../../src/tools/ai/ai.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIhD,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;AAE7F;;;;;;;;GAQG;AACH,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;YAAE,OAAO,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;QACvE,OAAO;YACL,MAAM,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4BAA4B,MAAM,CAAC,QAAQ,mBAAmB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACxH,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHY A CALL TO maka-cli.com DID NOT ARRIVE, in one sentence naming the
|
|
3
|
+
* origin actually dialled (board item KYaqmxeW343owAnsn).
|
|
4
|
+
*
|
|
5
|
+
* `maka login`, `maka logout` and `maka register` each print the right
|
|
6
|
+
* banner now (KtbaziFuKHh8WheFn) -- and then, when nothing answers,
|
|
7
|
+
* report the failure three DIFFERENT wrong ways:
|
|
8
|
+
*
|
|
9
|
+
* login exit 0, `console.log(e)` dumping the raw error object as a
|
|
10
|
+
* wall of node:net stack, then "If you need to reset your
|
|
11
|
+
* password..." -- advice for a failure that never happened.
|
|
12
|
+
* logout exit 0, `Log.error(e)` stringifying to the bare word
|
|
13
|
+
* "AggregateError", then "You may not be logged in...".
|
|
14
|
+
* register exit 1 (the only honest code of the three) and NO MESSAGE
|
|
15
|
+
* AT ALL, because `err.message` on an AggregateError is the
|
|
16
|
+
* empty string.
|
|
17
|
+
*
|
|
18
|
+
* Three spellings of one bug is worse than one uniform bug: it reads as
|
|
19
|
+
* three unrelated quirks, so nobody fixes the shape. Hence one helper
|
|
20
|
+
* all three share.
|
|
21
|
+
*
|
|
22
|
+
* THE EMPTY MESSAGE IS THE TRAP WORTH NAMING. Node raises AggregateError
|
|
23
|
+
* when a host resolves to several addresses (::1 and 127.0.0.1 for
|
|
24
|
+
* localhost) and every attempt fails; the real codes live on `.errors`,
|
|
25
|
+
* and `.message` is `''`. So the obvious `err.message` prints nothing,
|
|
26
|
+
* looks like a silent success, and is exactly how `register` came to
|
|
27
|
+
* announce a dead server by saying nothing whatsoever.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* The transport-level code buried in a thrown error, wherever it is.
|
|
31
|
+
*
|
|
32
|
+
* Looks in three places because Node uses all three: `code` on the error
|
|
33
|
+
* itself, `errors[]` on an AggregateError (the multi-address case), and
|
|
34
|
+
* `cause` on a wrapper. Depth-limited rather than trusting the shape --
|
|
35
|
+
* a cyclic `cause` is rare and a hung CLI is worse than a vague message.
|
|
36
|
+
*/
|
|
37
|
+
export declare function networkErrorCode(err: unknown, depth?: number): string | undefined;
|
|
38
|
+
/** Did this fail because the request never reached the server? Used to
|
|
39
|
+
* decide whether advice about PASSWORDS or SESSIONS is relevant -- it
|
|
40
|
+
* is not, when nobody was listening to hear the credentials. */
|
|
41
|
+
export declare function isUnreachable(err: unknown): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* One sentence, for a human, naming the origin that was actually
|
|
44
|
+
* dialled.
|
|
45
|
+
*
|
|
46
|
+
* NEVER RETURNS AN EMPTY STRING, and that is the load-bearing
|
|
47
|
+
* guarantee rather than a nicety: the bug being fixed here is a command
|
|
48
|
+
* that reported a dead server by printing nothing, and any fix that can
|
|
49
|
+
* still produce '' just moves that failure somewhere new.
|
|
50
|
+
*/
|
|
51
|
+
export declare function describeFailure(err: unknown, origin: string): string;
|
|
52
|
+
/** What a command should print and exit with, given a thrown error. */
|
|
53
|
+
export interface IFailureReport {
|
|
54
|
+
/** The one sentence. Never empty. */
|
|
55
|
+
message: string;
|
|
56
|
+
/** Follow-up advice, when any is warranted -- omitted for a failure the
|
|
57
|
+
* advice cannot explain. */
|
|
58
|
+
hint?: string;
|
|
59
|
+
/** Always non-zero: this is the failure path. */
|
|
60
|
+
exitCode: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* THE WHOLE FAILURE DECISION IN ONE PLACE, so the part with real cases
|
|
64
|
+
* in it can be tested without spawning a CLI.
|
|
65
|
+
*
|
|
66
|
+
* `login` and `logout` each ended their catch with `process.exit(0)`,
|
|
67
|
+
* which is the load-bearing half of KYaqmxeW343owAnsn: a login that
|
|
68
|
+
* never reached the server reported success, so `maka login && <next>`
|
|
69
|
+
* ran the next step regardless and nothing scripted could gate on it.
|
|
70
|
+
* A wrong exit code is a lie an automation acts on; a wrong message is
|
|
71
|
+
* only a lie a person reads.
|
|
72
|
+
*
|
|
73
|
+
* `hint` is dropped when the request never arrived, because both hints
|
|
74
|
+
* these commands carry -- "reset your password", "you may not be logged
|
|
75
|
+
* in" -- are guesses about CREDENTIALS or SESSION STATE, and neither is
|
|
76
|
+
* a sensible guess when nobody was listening to hear them. Advice that
|
|
77
|
+
* points the diagnosis away from a dead server is worse than none.
|
|
78
|
+
*/
|
|
79
|
+
export declare function failureReport(err: unknown, origin: string, hint?: string): IFailureReport;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHY A CALL TO maka-cli.com DID NOT ARRIVE, in one sentence naming the
|
|
3
|
+
* origin actually dialled (board item KYaqmxeW343owAnsn).
|
|
4
|
+
*
|
|
5
|
+
* `maka login`, `maka logout` and `maka register` each print the right
|
|
6
|
+
* banner now (KtbaziFuKHh8WheFn) -- and then, when nothing answers,
|
|
7
|
+
* report the failure three DIFFERENT wrong ways:
|
|
8
|
+
*
|
|
9
|
+
* login exit 0, `console.log(e)` dumping the raw error object as a
|
|
10
|
+
* wall of node:net stack, then "If you need to reset your
|
|
11
|
+
* password..." -- advice for a failure that never happened.
|
|
12
|
+
* logout exit 0, `Log.error(e)` stringifying to the bare word
|
|
13
|
+
* "AggregateError", then "You may not be logged in...".
|
|
14
|
+
* register exit 1 (the only honest code of the three) and NO MESSAGE
|
|
15
|
+
* AT ALL, because `err.message` on an AggregateError is the
|
|
16
|
+
* empty string.
|
|
17
|
+
*
|
|
18
|
+
* Three spellings of one bug is worse than one uniform bug: it reads as
|
|
19
|
+
* three unrelated quirks, so nobody fixes the shape. Hence one helper
|
|
20
|
+
* all three share.
|
|
21
|
+
*
|
|
22
|
+
* THE EMPTY MESSAGE IS THE TRAP WORTH NAMING. Node raises AggregateError
|
|
23
|
+
* when a host resolves to several addresses (::1 and 127.0.0.1 for
|
|
24
|
+
* localhost) and every attempt fails; the real codes live on `.errors`,
|
|
25
|
+
* and `.message` is `''`. So the obvious `err.message` prints nothing,
|
|
26
|
+
* looks like a silent success, and is exactly how `register` came to
|
|
27
|
+
* announce a dead server by saying nothing whatsoever.
|
|
28
|
+
*/
|
|
29
|
+
/** The failures that mean "the request never got there", mapped to what
|
|
30
|
+
* a person should do about it. Deliberately about REACHABILITY -- an
|
|
31
|
+
* HTTP status is a different thing and is reported by its own code. */
|
|
32
|
+
const NETWORK_REASONS = {
|
|
33
|
+
ECONNREFUSED: 'nothing is listening on that port',
|
|
34
|
+
ENOTFOUND: 'that host name does not resolve',
|
|
35
|
+
EAI_AGAIN: 'the DNS lookup failed',
|
|
36
|
+
ETIMEDOUT: 'it did not answer in time',
|
|
37
|
+
ECONNRESET: 'the connection was reset',
|
|
38
|
+
EHOSTUNREACH: 'that host is unreachable',
|
|
39
|
+
ENETUNREACH: 'that network is unreachable',
|
|
40
|
+
EPIPE: 'the connection closed mid-request',
|
|
41
|
+
CERT_HAS_EXPIRED: 'its TLS certificate has expired',
|
|
42
|
+
DEPTH_ZERO_SELF_SIGNED_CERT: 'its TLS certificate is self-signed',
|
|
43
|
+
UNABLE_TO_VERIFY_LEAF_SIGNATURE: 'its TLS certificate could not be verified',
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The transport-level code buried in a thrown error, wherever it is.
|
|
47
|
+
*
|
|
48
|
+
* Looks in three places because Node uses all three: `code` on the error
|
|
49
|
+
* itself, `errors[]` on an AggregateError (the multi-address case), and
|
|
50
|
+
* `cause` on a wrapper. Depth-limited rather than trusting the shape --
|
|
51
|
+
* a cyclic `cause` is rare and a hung CLI is worse than a vague message.
|
|
52
|
+
*/
|
|
53
|
+
export function networkErrorCode(err, depth = 0) {
|
|
54
|
+
if (err === null || typeof err !== 'object' || depth > 4)
|
|
55
|
+
return undefined;
|
|
56
|
+
const e = err;
|
|
57
|
+
if (typeof e.code === 'string' && e.code in NETWORK_REASONS)
|
|
58
|
+
return e.code;
|
|
59
|
+
if (Array.isArray(e.errors)) {
|
|
60
|
+
for (const inner of e.errors) {
|
|
61
|
+
const found = networkErrorCode(inner, depth + 1);
|
|
62
|
+
if (found)
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (e.cause !== undefined)
|
|
67
|
+
return networkErrorCode(e.cause, depth + 1);
|
|
68
|
+
// A code we do not have prose for still beats nothing: report it as
|
|
69
|
+
// itself rather than pretending the error was untyped.
|
|
70
|
+
if (typeof e.code === 'string' && e.code.length > 0)
|
|
71
|
+
return e.code;
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
/** Did this fail because the request never reached the server? Used to
|
|
75
|
+
* decide whether advice about PASSWORDS or SESSIONS is relevant -- it
|
|
76
|
+
* is not, when nobody was listening to hear the credentials. */
|
|
77
|
+
export function isUnreachable(err) {
|
|
78
|
+
return networkErrorCode(err) !== undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One sentence, for a human, naming the origin that was actually
|
|
82
|
+
* dialled.
|
|
83
|
+
*
|
|
84
|
+
* NEVER RETURNS AN EMPTY STRING, and that is the load-bearing
|
|
85
|
+
* guarantee rather than a nicety: the bug being fixed here is a command
|
|
86
|
+
* that reported a dead server by printing nothing, and any fix that can
|
|
87
|
+
* still produce '' just moves that failure somewhere new.
|
|
88
|
+
*/
|
|
89
|
+
export function describeFailure(err, origin) {
|
|
90
|
+
const code = networkErrorCode(err);
|
|
91
|
+
if (code !== undefined) {
|
|
92
|
+
const reason = NETWORK_REASONS[code];
|
|
93
|
+
return reason !== undefined
|
|
94
|
+
? `Could not reach ${origin} -- ${reason} (${code}).`
|
|
95
|
+
: `Could not reach ${origin} (${code}).`;
|
|
96
|
+
}
|
|
97
|
+
// Not a transport failure: the server answered and said no. Its own
|
|
98
|
+
// words are better than anything invented here.
|
|
99
|
+
const e = (err ?? {});
|
|
100
|
+
if (typeof e.statusMessage === 'string' && e.statusMessage.trim().length > 0) {
|
|
101
|
+
return e.statusMessage;
|
|
102
|
+
}
|
|
103
|
+
if (typeof e.message === 'string' && e.message.trim().length > 0) {
|
|
104
|
+
return e.message;
|
|
105
|
+
}
|
|
106
|
+
if (typeof err === 'string' && err.trim().length > 0)
|
|
107
|
+
return err;
|
|
108
|
+
return `Something went wrong talking to ${origin}.`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* THE WHOLE FAILURE DECISION IN ONE PLACE, so the part with real cases
|
|
112
|
+
* in it can be tested without spawning a CLI.
|
|
113
|
+
*
|
|
114
|
+
* `login` and `logout` each ended their catch with `process.exit(0)`,
|
|
115
|
+
* which is the load-bearing half of KYaqmxeW343owAnsn: a login that
|
|
116
|
+
* never reached the server reported success, so `maka login && <next>`
|
|
117
|
+
* ran the next step regardless and nothing scripted could gate on it.
|
|
118
|
+
* A wrong exit code is a lie an automation acts on; a wrong message is
|
|
119
|
+
* only a lie a person reads.
|
|
120
|
+
*
|
|
121
|
+
* `hint` is dropped when the request never arrived, because both hints
|
|
122
|
+
* these commands carry -- "reset your password", "you may not be logged
|
|
123
|
+
* in" -- are guesses about CREDENTIALS or SESSION STATE, and neither is
|
|
124
|
+
* a sensible guess when nobody was listening to hear them. Advice that
|
|
125
|
+
* points the diagnosis away from a dead server is worse than none.
|
|
126
|
+
*/
|
|
127
|
+
export function failureReport(err, origin, hint) {
|
|
128
|
+
return {
|
|
129
|
+
message: describeFailure(err, origin),
|
|
130
|
+
hint: hint !== undefined && !isUnreachable(err) ? hint : undefined,
|
|
131
|
+
exitCode: 1,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=connection-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-error.js","sourceRoot":"","sources":["../../../../../src/tools/https/connection-error.ts"],"names":[],"mappings":"AA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;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,MAAc,EAAE,IAAa;IACvE,OAAO;QACL,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC;QACrC,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAClE,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IHTTPSPost, IHTTPSGet, IHTTPSResponse, IHTPSAskGPT, IHTPSAskClaude, IHTTPSDownload } from './https.interface';
|
|
2
2
|
export declare class HTTPS {
|
|
3
|
-
static post({ hostname, path, data, headers, cert, timeout }: IHTTPSPost): Promise<IHTTPSResponse>;
|
|
3
|
+
static post({ hostname, path, data, headers, cert, timeout, port, protocol }: IHTTPSPost): Promise<IHTTPSResponse>;
|
|
4
4
|
static get({ url, headers, cert, timeout }: IHTTPSGet): Promise<IHTTPSResponse>;
|
|
5
5
|
static downloadFile({ url, headers, cert, destPath, timeout }: IHTTPSDownload): Promise<void>;
|
|
6
6
|
static checkAvailability({ url, headers, cert, maxRedirects, timeout }: IHTTPSGet & {
|