@genex-ai/embed-sdk 0.24.3 → 0.25.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 +71 -0
- package/dist/{chunk-EM5TVVSD.js → chunk-THXJ4IMO.js} +73 -3
- package/dist/development.d.ts +21 -2
- package/dist/development.js +14 -0
- package/dist/index.d.ts +46 -5
- package/dist/index.js +3 -1
- package/dist/sentry.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,6 +211,77 @@ and something that survives a reload. Validate `result.output` against the shape
|
|
|
211
211
|
your game expects before using it, always. It is data, never authority for
|
|
212
212
|
coins, rewards or items.
|
|
213
213
|
|
|
214
|
+
## Judge during play
|
|
215
|
+
|
|
216
|
+
SDK **0.25.0+**. `generate()` writes; `judge()` decides. A game that needs to
|
|
217
|
+
KNOW something about its own state — which mood the player is in, how
|
|
218
|
+
threatening a scene is on a scale, whether an NPC is lying — asks the budget's
|
|
219
|
+
classifier typed questions and gets calibrated probabilities back, typically in
|
|
220
|
+
about a third of a second. It writes no prose and invents no numbers, which is
|
|
221
|
+
exactly what makes it a steadier referee than a chat model asked to classify.
|
|
222
|
+
|
|
223
|
+
It is **grant-only** and **billed as used**: a call costs a small fraction of a
|
|
224
|
+
coin, so it is never charged a coin of its own. The budget holds a coin, calls
|
|
225
|
+
add up against it, and a whole coin is taken each time they reach one; when the
|
|
226
|
+
budget ends, a remainder is one coin and anything still held goes back. Ask for
|
|
227
|
+
it when you request the budget:
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
import { requestSpendGrant, judge, generationErrorMessage } from '@genex-ai/embed-sdk';
|
|
231
|
+
|
|
232
|
+
const budget = await requestSpendGrant({
|
|
233
|
+
models: [model.id], // or [] for a judge-only budget
|
|
234
|
+
perCallMaxCoins: 8, perCallEstimateCoins: 5,
|
|
235
|
+
disclosure: { periodLabel: 'minute', estimatedCallsPerPeriod: 4, estimatedCoinsPerPeriod: 20 },
|
|
236
|
+
judge: { enabled: true, estimatedCallsPerPeriod: 30 }, // honest checks per period
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const verdict = await judge({
|
|
240
|
+
grantId: budget.grantId!,
|
|
241
|
+
state: { npc: 'Mara', said: 'I never touched the key', evidence: ['key in her pocket'] },
|
|
242
|
+
questions: {
|
|
243
|
+
lying: { type: 'noul', instructions: 'Is the NPC lying about the key?' },
|
|
244
|
+
mood: { type: 'choice', instructions: 'What is the NPC\'s mood?',
|
|
245
|
+
criteria: { calm: 'Relaxed and cooperative', defensive: { what: 'Guarded, deflecting', not_for: 'Openly hostile' } } },
|
|
246
|
+
threat: { type: 'score', instructions: 'How dangerous is the NPC right now?', criteria: ['harmless', 'wary', 'dangerous'] },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
if (verdict.status === 'succeeded') {
|
|
250
|
+
const lying = verdict.answers!.lying; // { type: 'noul', noul: 0.87 }
|
|
251
|
+
if (lying.type === 'noul' && lying.noul > 0.7) accuse();
|
|
252
|
+
} else showNotice(generationErrorMessage(verdict.error));
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The sheet tells the player the game also uses a fast classifier billed as used,
|
|
256
|
+
with Genex's own worst case for your declared calls per period beside your
|
|
257
|
+
estimate. Up to 64 questions per call: `choice` (2–255 named options, each a
|
|
258
|
+
description or `{ what, not_for?, examples? }`), `score` (2–10 levels, lowest
|
|
259
|
+
first) and `noul` (yes/no, `criteria: { true, false }` optional); every text
|
|
260
|
+
field is at most 2000 characters and `state` any JSON up to 96 KB. Each answer
|
|
261
|
+
has the type its question asked: `{ choice, probabilities }`,
|
|
262
|
+
`{ score, probabilities }` or `{ noul }` (a probability, not a boolean — pick
|
|
263
|
+
your own threshold).
|
|
264
|
+
|
|
265
|
+
`judge()` needs the budget and applies every guard a budget `generate()` does;
|
|
266
|
+
it opens no window. The answer arrives in the same response; reuse an
|
|
267
|
+
`idempotencyKey` to retry the same call without paying twice. A call that times
|
|
268
|
+
out (`timeoutMs`, 1000–20000) is `unknown` and billed at its maximum, because
|
|
269
|
+
the work may have run. The refusals to handle as game states:
|
|
270
|
+
`judge_requires_grant` (no budget), `judge_not_enabled` (the budget was approved
|
|
271
|
+
without the judge — request a new one), `judge_requires_coins`,
|
|
272
|
+
`judge_period_limit` (the checks reached the per-period ceiling the player was
|
|
273
|
+
shown — it rolls, so try again shortly), `judge_busy` and `judge_paused` (the
|
|
274
|
+
platform's, retry later), `request_too_large` (state and questions over the
|
|
275
|
+
byte bound), and every budget code above — `grant_concurrency` now also means
|
|
276
|
+
"fits once calls in flight land", never an ended budget. The receipt is on `verdict.billing` (`chargedCoins` is always
|
|
277
|
+
0; `chargedUsdPicos` is what this call added); the budget's `spentCoins` and
|
|
278
|
+
`heldCoins` are the numbers to show.
|
|
279
|
+
|
|
280
|
+
Benchmark on your own coins with `developmentJudge()` from
|
|
281
|
+
`@genex-ai/embed-sdk/development` (same shape, `{ maxCoins, request }`). It is
|
|
282
|
+
billed one whole coin a call on your wallet — a player's budget, which meters,
|
|
283
|
+
spends far less for the same calls.
|
|
284
|
+
|
|
214
285
|
## Your subscription and the Genex player watcher
|
|
215
286
|
|
|
216
287
|
Both approval sheets can offer the player their own Claude or ChatGPT plan
|
|
@@ -310,7 +310,9 @@ function validCount(value, min, max) {
|
|
|
310
310
|
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
311
311
|
}
|
|
312
312
|
function invalidGrantOptions(options) {
|
|
313
|
-
|
|
313
|
+
const judge2 = options.judge;
|
|
314
|
+
if (judge2 !== void 0 && (typeof judge2 !== "object" || judge2 === null || typeof judge2.enabled !== "boolean" || !validCount(judge2.estimatedCallsPerPeriod, 1, 1e5))) return "invalid_judge_terms";
|
|
315
|
+
if (!Array.isArray(options.models) || options.models.length < (judge2?.enabled ? 0 : 1) || options.models.length > 8 || options.models.some((id) => typeof id !== "string" || !id || id.length > 150) || new Set(options.models).size !== options.models.length) return "invalid_models";
|
|
314
316
|
if (!validCount(options.perCallMaxCoins, 1, 1e6) || !validCount(options.perCallEstimateCoins, 1, 1e6) || options.perCallEstimateCoins > options.perCallMaxCoins) return "invalid_declared_price";
|
|
315
317
|
const d = options.disclosure;
|
|
316
318
|
if (!d || typeof d !== "object" || !["minute", "hour", "session"].includes(d.periodLabel) || !validCount(d.estimatedCallsPerPeriod, 1, 1e4) || !validCount(d.estimatedCoinsPerPeriod, 0, 1e6)) return "invalid_disclosure";
|
|
@@ -383,7 +385,8 @@ async function requestSpendGrant(options) {
|
|
|
383
385
|
...options.maxConcurrent !== void 0 ? { maxConcurrent: options.maxConcurrent } : {},
|
|
384
386
|
...options.maxCallsPerMinute !== void 0 ? { maxCallsPerMinute: options.maxCallsPerMinute } : {},
|
|
385
387
|
...options.maxPendingExternal !== void 0 ? { maxPendingExternal: options.maxPendingExternal } : {},
|
|
386
|
-
...options.allowExternal !== void 0 ? { allowExternal: options.allowExternal } : {}
|
|
388
|
+
...options.allowExternal !== void 0 ? { allowExternal: options.allowExternal } : {},
|
|
389
|
+
...options.judge !== void 0 ? { judge: { enabled: options.judge.enabled, estimatedCallsPerPeriod: options.judge.estimatedCallsPerPeriod } } : {}
|
|
387
390
|
});
|
|
388
391
|
if (!isGrantId(view.id)) throw new Error("invalid_grant_response");
|
|
389
392
|
const settled = grantOutcome(view);
|
|
@@ -420,6 +423,57 @@ async function generateUnderGrant(grantId, input, idempotencyKey, timeoutMs) {
|
|
|
420
423
|
return { status: "failed", error: error instanceof Error ? error.message : "generation_unavailable" };
|
|
421
424
|
}
|
|
422
425
|
}
|
|
426
|
+
var JUDGE_QUESTION_NAME = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
427
|
+
function invalidJudgeOptions(options) {
|
|
428
|
+
if (options.grantId === void 0 || options.grantId === null) return "judge_requires_grant";
|
|
429
|
+
if (!isGrantId(options.grantId)) return "invalid_grant_id";
|
|
430
|
+
if (options.state === void 0) return "invalid_request";
|
|
431
|
+
const questions = options.questions;
|
|
432
|
+
if (!questions || typeof questions !== "object" || Array.isArray(questions)) return "invalid_request";
|
|
433
|
+
const names = Object.keys(questions);
|
|
434
|
+
if (names.length < 1 || names.length > 64 || names.some((name) => !JUDGE_QUESTION_NAME.test(name))) return "invalid_request";
|
|
435
|
+
if (names.some((name) => !["choice", "score", "noul"].includes(questions[name]?.type))) return "invalid_request";
|
|
436
|
+
if (options.timeoutMs !== void 0 && !validCount(options.timeoutMs, 1e3, 2e4)) return "invalid_timeout";
|
|
437
|
+
if (options.idempotencyKey !== void 0 && (typeof options.idempotencyKey !== "string" || options.idempotencyKey.length < 8 || options.idempotencyKey.length > 100)) return "invalid_idempotency_key";
|
|
438
|
+
return void 0;
|
|
439
|
+
}
|
|
440
|
+
function judgeOutcome(view) {
|
|
441
|
+
if (!isGenerationTerminal(view.status)) return void 0;
|
|
442
|
+
return {
|
|
443
|
+
status: view.status === "expired" ? "failed" : view.status,
|
|
444
|
+
generationId: view.id,
|
|
445
|
+
...view.status === "succeeded" ? { answers: view.output } : {},
|
|
446
|
+
...view.error ? { error: view.error } : {}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
async function judge(options) {
|
|
450
|
+
const invalid = invalidJudgeOptions(options);
|
|
451
|
+
if (invalid) return { status: "failed", error: invalid };
|
|
452
|
+
const guarded = approvalGuards();
|
|
453
|
+
if ("status" in guarded) return guarded;
|
|
454
|
+
try {
|
|
455
|
+
const view = await request(`/grants/${encodeURIComponent(options.grantId)}/judgments`, {
|
|
456
|
+
idempotencyKey: options.idempotencyKey ?? crypto.randomUUID(),
|
|
457
|
+
state: options.state,
|
|
458
|
+
questions: options.questions,
|
|
459
|
+
...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {}
|
|
460
|
+
});
|
|
461
|
+
if (!isGenerationId(view.generationId) || view.grantId !== options.grantId) throw new Error("invalid_judgment_response");
|
|
462
|
+
if (view.status === "dispatching") {
|
|
463
|
+
const settled = await poll(view.generationId, (options.timeoutMs ?? 2e4) + 1e4, judgeOutcome);
|
|
464
|
+
return settled.status === "pending" ? { ...settled, billing: view.billing } : settled;
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
status: view.status,
|
|
468
|
+
generationId: view.generationId,
|
|
469
|
+
billing: view.billing,
|
|
470
|
+
...view.answers ? { answers: view.answers } : {},
|
|
471
|
+
...view.error ? { error: view.error } : {}
|
|
472
|
+
};
|
|
473
|
+
} catch (error) {
|
|
474
|
+
return { status: "failed", error: error instanceof Error ? error.message : "judge_unavailable" };
|
|
475
|
+
}
|
|
476
|
+
}
|
|
423
477
|
function generationErrorMessage(code) {
|
|
424
478
|
switch (code) {
|
|
425
479
|
// --- the outcome is not known yet. Never a failure sentence. ------------
|
|
@@ -456,6 +510,21 @@ function generationErrorMessage(code) {
|
|
|
456
510
|
return "A budget on your own plan is already running. Stop it on Genex before setting up another.";
|
|
457
511
|
case "invalid_grant_limit":
|
|
458
512
|
return "That limit is outside the range Genex offers. Choose one on the slider.";
|
|
513
|
+
// --- the judge ------------------------------------------------------------
|
|
514
|
+
case "judge_requires_grant":
|
|
515
|
+
return "This game\u2019s quick checks run under a budget you approve. Set one up to keep going.";
|
|
516
|
+
case "judge_not_enabled":
|
|
517
|
+
return "This budget doesn\u2019t cover the game\u2019s quick checks. Set up a new one to keep going.";
|
|
518
|
+
case "judge_requires_coins":
|
|
519
|
+
return "The game\u2019s quick checks are paid from your Genex wallet, not your own plan.";
|
|
520
|
+
case "invalid_judge_terms":
|
|
521
|
+
return "This budget request isn\u2019t valid, so nothing was requested.";
|
|
522
|
+
case "judge_period_limit":
|
|
523
|
+
return "The game\u2019s quick checks have reached the most your budget allows for now. They pick up again shortly.";
|
|
524
|
+
case "judge_busy":
|
|
525
|
+
return "The game\u2019s quick checks are busy right now. Try again in a moment.";
|
|
526
|
+
case "judge_paused":
|
|
527
|
+
return "The game\u2019s quick checks are paused for now. Try again later.";
|
|
459
528
|
case "waiting_for_plan":
|
|
460
529
|
return "Your own plan is at its rate limit right now. This resumes on its own once the limit resets.";
|
|
461
530
|
// --- personal plans and the player watcher ------------------------------
|
|
@@ -577,7 +646,7 @@ var RETRY_FLAG = "genex:embed:retry";
|
|
|
577
646
|
var POPOVER_DISMISSED_FLAG = "genex:guest:popover-dismissed";
|
|
578
647
|
var LOCAL_AUTH_FLAG = "genex:embed:local-auth";
|
|
579
648
|
var PLAYER_ID_KEY = "genex:player";
|
|
580
|
-
var SDK_VERSION = "0.
|
|
649
|
+
var SDK_VERSION = "0.25.0";
|
|
581
650
|
var config2 = null;
|
|
582
651
|
var state = "pending";
|
|
583
652
|
var user = null;
|
|
@@ -1831,6 +1900,7 @@ export {
|
|
|
1831
1900
|
getSpendGrant,
|
|
1832
1901
|
stopSpendGrant,
|
|
1833
1902
|
requestSpendGrant,
|
|
1903
|
+
judge,
|
|
1834
1904
|
generationErrorMessage,
|
|
1835
1905
|
initEmbed,
|
|
1836
1906
|
isEmbedded,
|
package/dist/development.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeWorkflowInput, RuntimeGenerationView } from '@genex/embed-protocol';
|
|
1
|
+
import { RuntimeJudgeQuestion, RuntimeWorkflowInput, RuntimeGenerationView } from '@genex/embed-protocol';
|
|
2
2
|
|
|
3
3
|
/** Server-only benchmarks spend the authenticated creator's own coin wallet. */
|
|
4
4
|
|
|
@@ -32,6 +32,25 @@ interface DevelopmentWorkflowOptions extends DevelopmentGenerationConfig {
|
|
|
32
32
|
}
|
|
33
33
|
/** Create a generic benchmark and wait for execution and its actual-usage receipt. */
|
|
34
34
|
declare function developmentGenerate(options: DevelopmentGenerationOptions): Promise<RuntimeGenerationView>;
|
|
35
|
+
interface DevelopmentJudgeOptions extends DevelopmentGenerationConfig {
|
|
36
|
+
/** Explicit maximum reservation in your own coins. Each call is charged at the
|
|
37
|
+
* lane's one-coin minimum (`consumed-v1`), a refusal before any work at zero. */
|
|
38
|
+
maxCoins: number;
|
|
39
|
+
request: {
|
|
40
|
+
state: unknown;
|
|
41
|
+
questions: Record<string, RuntimeJudgeQuestion>;
|
|
42
|
+
idempotencyKey?: string;
|
|
43
|
+
/** How long the server waits for the classifier, 1000–20000 ms. */
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The judge on the creator's OWN wallet, answered in the same response. Unlike
|
|
49
|
+
* a player's budget — which meters judge calls and moves whole coins only as
|
|
50
|
+
* they add up — a development call is billed at the one-coin minimum, so a
|
|
51
|
+
* bench here overstates what a budget would spend on the same calls.
|
|
52
|
+
*/
|
|
53
|
+
declare function developmentJudge(options: DevelopmentJudgeOptions): Promise<RuntimeGenerationView>;
|
|
35
54
|
/** Returns the accepted workflow so its trusted executor can enqueue before waiting. */
|
|
36
55
|
declare function developmentRequestWorkflow(options: DevelopmentWorkflowOptions): Promise<RuntimeGenerationView>;
|
|
37
56
|
/** Recover a benchmark with the same creator and project; no play token is used. */
|
|
@@ -41,4 +60,4 @@ declare function cancelDevelopmentGeneration(config: DevelopmentGenerationConfig
|
|
|
41
60
|
/** Wait for execution and final billing; timeout preserves the latest pending receipt. */
|
|
42
61
|
declare function waitForDevelopmentGeneration(config: DevelopmentGenerationConfig, generationId: string, timeoutMs?: number): Promise<RuntimeGenerationView>;
|
|
43
62
|
|
|
44
|
-
export { type DevelopmentGenerationConfig, type DevelopmentGenerationOptions, type DevelopmentWorkflowOptions, cancelDevelopmentGeneration, developmentGenerate, developmentRequestWorkflow, getDevelopmentGeneration, waitForDevelopmentGeneration };
|
|
63
|
+
export { type DevelopmentGenerationConfig, type DevelopmentGenerationOptions, type DevelopmentJudgeOptions, type DevelopmentWorkflowOptions, cancelDevelopmentGeneration, developmentGenerate, developmentJudge, developmentRequestWorkflow, getDevelopmentGeneration, waitForDevelopmentGeneration };
|
package/dist/development.js
CHANGED
|
@@ -48,6 +48,19 @@ async function developmentGenerate(options) {
|
|
|
48
48
|
} });
|
|
49
49
|
return wait(options, view, options.timeoutMs ?? 6e5);
|
|
50
50
|
}
|
|
51
|
+
async function developmentJudge(options) {
|
|
52
|
+
validateMaximum(options.maxCoins);
|
|
53
|
+
const input = options.request;
|
|
54
|
+
if (!input || input.state === void 0 || !input.questions || typeof input.questions !== "object") throw new Error("invalid_request");
|
|
55
|
+
const view = await request(options, "/judgments", { maxCoins: options.maxCoins, request: {
|
|
56
|
+
state: input.state,
|
|
57
|
+
questions: input.questions,
|
|
58
|
+
...input.timeoutMs === void 0 ? {} : { timeoutMs: input.timeoutMs },
|
|
59
|
+
idempotencyKey: input.idempotencyKey ?? crypto.randomUUID()
|
|
60
|
+
} });
|
|
61
|
+
if (view.outputFormat !== "judge") throw new Error("invalid_development_response");
|
|
62
|
+
return view;
|
|
63
|
+
}
|
|
51
64
|
async function developmentRequestWorkflow(options) {
|
|
52
65
|
validateMaximum(options.maxCoins);
|
|
53
66
|
assertIdentifier(options.workflowId);
|
|
@@ -93,6 +106,7 @@ async function waitForDevelopmentGeneration(config, generationId, timeoutMs = 6e
|
|
|
93
106
|
export {
|
|
94
107
|
cancelDevelopmentGeneration,
|
|
95
108
|
developmentGenerate,
|
|
109
|
+
developmentJudge,
|
|
96
110
|
developmentRequestWorkflow,
|
|
97
111
|
getDevelopmentGeneration,
|
|
98
112
|
waitForDevelopmentGeneration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RuntimeWorkflowInput, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGrantView, RuntimeGenerationView, RuntimeGenerationModels, RuntimeWorkflowOfferings } from '@genex/embed-protocol';
|
|
2
|
-
export { RuntimeBillingPolicy, RuntimeExternalProvider, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGenerationModels, RuntimeGenerationStatus, RuntimeGenerationView, RuntimeGrantStatus, RuntimeGrantTerms, RuntimeGrantView, RuntimeWorkflowInput, RuntimeWorkflowOfferings } from '@genex/embed-protocol';
|
|
1
|
+
import { RuntimeJudgeQuestion, RuntimeJudgeAnswer, RuntimeJudgmentView, RuntimeWorkflowInput, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGrantView, RuntimeGenerationView, RuntimeGenerationModels, RuntimeWorkflowOfferings } from '@genex/embed-protocol';
|
|
2
|
+
export { RuntimeBillingPolicy, RuntimeExternalProvider, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGenerationModels, RuntimeGenerationStatus, RuntimeGenerationView, RuntimeGrantJudgeTerms, RuntimeGrantStatus, RuntimeGrantTerms, RuntimeGrantView, RuntimeJudgeAnswer, RuntimeJudgeCriterion, RuntimeJudgeQuestion, RuntimeJudgmentView, RuntimeWorkflowInput, RuntimeWorkflowOfferings } from '@genex/embed-protocol';
|
|
3
3
|
|
|
4
4
|
/** A thing the game sells. Resolved server-side; the game never sets a price. */
|
|
5
5
|
interface ShopItem {
|
|
@@ -146,8 +146,9 @@ interface RuntimeGenerationResult extends RuntimeGenerationBilling {
|
|
|
146
146
|
status: 'succeeded' | 'failed' | 'unknown' | 'canceled' | 'expired' | 'pending';
|
|
147
147
|
generationId?: string;
|
|
148
148
|
output?: unknown;
|
|
149
|
-
/** External output is user-supplied; never use it as authority for rewards or money.
|
|
150
|
-
|
|
149
|
+
/** External output is user-supplied; never use it as authority for rewards or money.
|
|
150
|
+
* `typesafe` appears only on a judge call read back through getGeneration(). */
|
|
151
|
+
source?: 'openrouter' | 'external' | 'typesafe';
|
|
151
152
|
modelProvenance?: 'unverified';
|
|
152
153
|
error?: string;
|
|
153
154
|
}
|
|
@@ -223,6 +224,17 @@ interface SpendGrantOptions {
|
|
|
223
224
|
maxPendingExternal?: number;
|
|
224
225
|
/** Offer the player's own Claude/ChatGPT plan beside coins. Defaults off. */
|
|
225
226
|
allowExternal?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* The game also calls judge() — a fast classifier billed as used rather than
|
|
229
|
+
* per request. The sheet tells the player so, beside the server's own worst
|
|
230
|
+
* case for `estimatedCallsPerPeriod` calls per `disclosure.periodLabel`. A
|
|
231
|
+
* budget with the judge is coin-funded: `allowExternal` offers nothing on it.
|
|
232
|
+
* With `enabled: true`, `models` may be empty for a judge-only budget.
|
|
233
|
+
*/
|
|
234
|
+
judge?: {
|
|
235
|
+
enabled: boolean;
|
|
236
|
+
estimatedCallsPerPeriod: number;
|
|
237
|
+
};
|
|
226
238
|
/** Reuse for the same budget request across retries and reloads. */
|
|
227
239
|
idempotencyKey?: string;
|
|
228
240
|
/** Approval waiting time only. A timeout neither cancels nor charges. */
|
|
@@ -255,6 +267,35 @@ declare function stopSpendGrant(grantId: string): Promise<RuntimeGrantView>;
|
|
|
255
267
|
* Store the id: getSpendGrant(id) recovers the budget after a reload.
|
|
256
268
|
*/
|
|
257
269
|
declare function requestSpendGrant(options: SpendGrantOptions): Promise<SpendGrantResult>;
|
|
270
|
+
interface JudgeOptions {
|
|
271
|
+
/** A standing budget from requestSpendGrant({ judge: { enabled: true, … } }). Required. */
|
|
272
|
+
grantId: string;
|
|
273
|
+
/** Whatever the questions are about: any JSON value, at most 96 KB serialized. */
|
|
274
|
+
state: unknown;
|
|
275
|
+
/** One to 64 named questions (a name starts with a letter; letters, digits, `_`). */
|
|
276
|
+
questions: Record<string, RuntimeJudgeQuestion>;
|
|
277
|
+
/** Reuse for retries of the same call: a replay is answered, never billed twice. */
|
|
278
|
+
idempotencyKey?: string;
|
|
279
|
+
/** How long the server waits for the classifier, 1000–20000 ms. A call that
|
|
280
|
+
* times out is `unknown` and billed at its maximum — it may have run. */
|
|
281
|
+
timeoutMs?: number;
|
|
282
|
+
}
|
|
283
|
+
interface JudgeResult {
|
|
284
|
+
status: 'succeeded' | 'failed' | 'unknown' | 'canceled' | 'pending';
|
|
285
|
+
generationId?: string;
|
|
286
|
+
/** One typed answer per question; present only on `succeeded`. */
|
|
287
|
+
answers?: Record<string, RuntimeJudgeAnswer>;
|
|
288
|
+
error?: string;
|
|
289
|
+
/** Where the call's money went: never a coin of its own, always the budget's meter. */
|
|
290
|
+
billing?: RuntimeJudgmentView['billing'];
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Ask the budget's classifier. No popup, no user gesture — the player approved
|
|
294
|
+
* the budget once — and every other guard generate({ grantId }) applies. The
|
|
295
|
+
* answer arrives in the same response; a replay of a call still running waits
|
|
296
|
+
* for it.
|
|
297
|
+
*/
|
|
298
|
+
declare function judge(options: JudgeOptions): Promise<JudgeResult>;
|
|
258
299
|
/**
|
|
259
300
|
* A player-facing sentence for any code this lane can put in `result.error`.
|
|
260
301
|
*
|
|
@@ -526,4 +567,4 @@ declare function __resetForTests(overrides?: {
|
|
|
526
567
|
heartbeatIntervalMs?: number;
|
|
527
568
|
}): void;
|
|
528
569
|
|
|
529
|
-
export { type AuthState, type EmbedConfig, type EmbedEvent, type EmbedUser, type Entitlement, type GenerateOptions, type Leaderboard, type LeaderboardEntry, type PlayerStateResult, type PurchaseResult, type PurchaseStatus, type RequestWorkflowOptions, type RuntimeGenerationResult, type RuntimeWorkflowAuthorization, type SaveStateResult, type ShopItem, type SpendGrantDisclosure, type SpendGrantOptions, type SpendGrantResult, type SubmitScoreResult, type WorldStateResult, __resetForTests, _stashTicketFromUrl, buy, consumeEntitlement, generate, generationErrorMessage, getAuthState, getColyseusAuth, getColyseusUrls, getEmbedToken, getEntitlements, getGeneration, getGenerationModels, getLeaderboard, getShop, getSpendGrant, getUser, getWorkflowOfferings, initEmbed, isEmbedded, loadPlayerState, loadWorldState, on, requestSpendGrant, requestWorkflow, resumeWorkflow, savePlayerState, saveWorldState, stopSpendGrant, submitScore, waitForAuth, waitForGeneration, waitForPlayer };
|
|
570
|
+
export { type AuthState, type EmbedConfig, type EmbedEvent, type EmbedUser, type Entitlement, type GenerateOptions, type JudgeOptions, type JudgeResult, type Leaderboard, type LeaderboardEntry, type PlayerStateResult, type PurchaseResult, type PurchaseStatus, type RequestWorkflowOptions, type RuntimeGenerationResult, type RuntimeWorkflowAuthorization, type SaveStateResult, type ShopItem, type SpendGrantDisclosure, type SpendGrantOptions, type SpendGrantResult, type SubmitScoreResult, type WorldStateResult, __resetForTests, _stashTicketFromUrl, buy, consumeEntitlement, generate, generationErrorMessage, getAuthState, getColyseusAuth, getColyseusUrls, getEmbedToken, getEntitlements, getGeneration, getGenerationModels, getLeaderboard, getShop, getSpendGrant, getUser, getWorkflowOfferings, initEmbed, isEmbedded, judge, loadPlayerState, loadWorldState, on, requestSpendGrant, requestWorkflow, resumeWorkflow, savePlayerState, saveWorldState, stopSpendGrant, submitScore, waitForAuth, waitForGeneration, waitForPlayer };
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
getWorkflowOfferings,
|
|
20
20
|
initEmbed,
|
|
21
21
|
isEmbedded,
|
|
22
|
+
judge,
|
|
22
23
|
loadPlayerState,
|
|
23
24
|
loadWorldState,
|
|
24
25
|
on,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
waitForAuth,
|
|
33
34
|
waitForGeneration,
|
|
34
35
|
waitForPlayer
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-THXJ4IMO.js";
|
|
36
37
|
import "./chunk-VPIQVRVS.js";
|
|
37
38
|
export {
|
|
38
39
|
__resetForTests,
|
|
@@ -55,6 +56,7 @@ export {
|
|
|
55
56
|
getWorkflowOfferings,
|
|
56
57
|
initEmbed,
|
|
57
58
|
isEmbedded,
|
|
59
|
+
judge,
|
|
58
60
|
loadPlayerState,
|
|
59
61
|
loadWorldState,
|
|
60
62
|
on,
|
package/dist/sentry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genex-ai/embed-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Player identity + durable game state for genex games \u2014 signed-in or guest play, per-player save slots, shared world state, and soft-trust leaderboards.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|