@bendyline/gezel-sdk 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checks.d.ts +2 -19
- package/dist/checks.js +21 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/portable.d.ts +38 -7
- package/dist/portable.js +4 -0
- package/dist/{types-rOo0kM35.d.ts → types-B03jHCAe.d.ts} +1 -1
- package/package.json +2 -2
package/dist/checks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GateScriptResult } from './types-
|
|
1
|
+
import { G as GateScriptResult } from './types-B03jHCAe.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ─ Shared deliverable checks ─────────────────────────────────────────
|
|
@@ -148,23 +148,6 @@ declare function inlineJsBytes(html: string): number;
|
|
|
148
148
|
* AND a closing `</body>` or `</html>`.
|
|
149
149
|
*/
|
|
150
150
|
declare function htmlCompleteSniff(html: string): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* "Plausibly a real browser game": a game *surface*, at least one CLOSED
|
|
153
|
-
* script, and non-trivial inline JS (default floor 400 bytes —
|
|
154
|
-
* `advanceWhen.minBytes` guards total size separately).
|
|
155
|
-
*
|
|
156
|
-
* A "surface" is a canvas/SVG render target OR a real animation/tick loop
|
|
157
|
-
* (`requestAnimationFrame`, `setInterval`/`setTimeout`, or a conventional
|
|
158
|
-
* frame function). The loop branch matters: plenty of legitimate games —
|
|
159
|
-
* board games, multi-screen arcade games, anything that animates by
|
|
160
|
-
* mutating the DOM each frame — never touch `<canvas>`. Requiring a
|
|
161
|
-
* canvas held 2 of 3 genuinely-passing DOM arcade games at the build gate
|
|
162
|
-
* gate-liveness run, while the eval grader (which
|
|
163
|
-
* treats render-surface as one optional signal of six) passed all three.
|
|
164
|
-
* The gate must agree with the grader on what "is a game" means — canvas
|
|
165
|
-
* is one way to be a game, not the definition. The closed-script +
|
|
166
|
-
* substantial-JS floors still exclude static pages and truncated stubs.
|
|
167
|
-
*/
|
|
168
151
|
declare function htmlGameSniff(html: string, minJsBytes?: number): boolean;
|
|
169
152
|
|
|
170
153
|
/**
|
|
@@ -757,7 +740,7 @@ type ExplainableSniff = 'html-complete' | 'html-game' | 'nonempty' | 'json-valid
|
|
|
757
740
|
* that actually passes, a generic line is returned rather than lying
|
|
758
741
|
* about a defect.
|
|
759
742
|
*/
|
|
760
|
-
declare function explainSniff(name: ExplainableSniff, content: string): string;
|
|
743
|
+
declare function explainSniff(name: ExplainableSniff, content: string, minGameJsBytes?: number): string;
|
|
761
744
|
|
|
762
745
|
/**
|
|
763
746
|
* Pure helpers for the LLM-judge gate check (`kind: 'judge'`) —
|
package/dist/checks.js
CHANGED
|
@@ -92,16 +92,25 @@ function htmlCompleteSniff(html) {
|
|
|
92
92
|
const closedDoc = lower.includes("</body>") || lower.includes("</html>");
|
|
93
93
|
return scriptsBalanced && closedDoc;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function hasHtmlGameSurface(html) {
|
|
96
96
|
const lower = html.toLowerCase();
|
|
97
97
|
const hasRenderTarget = /<canvas\b/.test(lower) || /<svg\b/.test(lower);
|
|
98
98
|
const hasFrameLoop = /requestanimationframe\s*\(/.test(lower) || /set(?:interval|timeout)\s*\(/.test(lower) || /\bfunction\s+(?:tick|update|loop|gameloop|gametick|step|render|frame)\b/.test(lower);
|
|
99
|
-
const
|
|
99
|
+
const scripts = extractInlineScripts(html).map((script) => script.body).join("\n");
|
|
100
|
+
const hasDomInteraction = /<(?:button|input|select)\b|\b(?:tabindex|role)\s*=/i.test(html) && /\.addEventListener\s*\(\s*['"](?:click|pointerdown|pointerup|mousedown|mouseup|keydown|keyup|touchstart|touchend|change)['"]|\.on(?:click|keydown|pointerdown)\s*=/.test(
|
|
101
|
+
scripts
|
|
102
|
+
) && /\.(?:textContent|innerHTML|innerText)\s*=|\.(?:replaceChildren|appendChild|setAttribute)\s*\(|\.classList\.(?:add|remove|toggle)\s*\(/.test(
|
|
103
|
+
scripts
|
|
104
|
+
);
|
|
105
|
+
return hasRenderTarget || hasFrameLoop || hasDomInteraction;
|
|
106
|
+
}
|
|
107
|
+
function htmlGameSniff(html, minJsBytes = 400) {
|
|
108
|
+
const lower = html.toLowerCase();
|
|
100
109
|
const opens = (lower.match(/<script\b/g) ?? []).length;
|
|
101
110
|
const closes = (lower.match(/<\/script>/g) ?? []).length;
|
|
102
111
|
const scriptClosed = opens > 0 && opens === closes;
|
|
103
112
|
const jsSubstantial = inlineJsBytes(html) >= minJsBytes;
|
|
104
|
-
return
|
|
113
|
+
return hasHtmlGameSurface(html) && scriptClosed && jsSubstantial;
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
// ../core/src/checks/records.ts
|
|
@@ -2270,7 +2279,7 @@ async function markdownHeadingsMatch(ws, file, outlineFile, outlineWs = ws) {
|
|
|
2270
2279
|
}
|
|
2271
2280
|
|
|
2272
2281
|
// ../core/src/checks/sniff-explain.ts
|
|
2273
|
-
function explainSniff(name, content) {
|
|
2282
|
+
function explainSniff(name, content, minGameJsBytes = 400) {
|
|
2274
2283
|
switch (name) {
|
|
2275
2284
|
case "html-complete": {
|
|
2276
2285
|
const scripts = detectUnclosedScript(content);
|
|
@@ -2284,22 +2293,19 @@ function explainSniff(name, content) {
|
|
|
2284
2293
|
return "the document is incomplete \u2014 finish and close it.";
|
|
2285
2294
|
}
|
|
2286
2295
|
case "html-game": {
|
|
2287
|
-
const lower = content.toLowerCase();
|
|
2288
|
-
const hasRenderTarget = /<canvas\b/.test(lower) || /<svg\b/.test(lower);
|
|
2289
|
-
const hasFrameLoop = /requestanimationframe\s*\(/.test(lower) || /set(?:interval|timeout)\s*\(/.test(lower) || /\bfunction\s+(?:tick|update|loop|gameloop|gametick|step|render|frame)\b/.test(lower);
|
|
2290
|
-
if (!hasRenderTarget && !hasFrameLoop) {
|
|
2291
|
-
return "no render surface (<canvas>/<svg>) and no frame loop (requestAnimationFrame / setInterval / a tick()/update() function) \u2014 add the game loop.";
|
|
2292
|
-
}
|
|
2293
2296
|
const scripts = detectUnclosedScript(content);
|
|
2294
|
-
if (scripts.opens === 0) {
|
|
2295
|
-
return "no <script> block \u2014 the page has no game logic; add the inline script.";
|
|
2296
|
-
}
|
|
2297
2297
|
if (scripts.unclosed) {
|
|
2298
2298
|
return `${scripts.opens} <script> tag${scripts.opens === 1 ? "" : "s"} open but only ${scripts.closes} close${scripts.closes === 1 ? "s" : ""} \u2014 truncated mid-script; close the script.`;
|
|
2299
2299
|
}
|
|
2300
|
+
if (!hasHtmlGameSurface(content)) {
|
|
2301
|
+
return "no render surface, frame loop, or interactive DOM controls that update the display \u2014 connect the game state to a visible playable surface.";
|
|
2302
|
+
}
|
|
2303
|
+
if (scripts.opens === 0) {
|
|
2304
|
+
return "no <script> block \u2014 the page has no game logic; add the inline script.";
|
|
2305
|
+
}
|
|
2300
2306
|
const js = inlineJsBytes(content);
|
|
2301
|
-
if (js <
|
|
2302
|
-
return `inline JavaScript is ${js} bytes, need >=
|
|
2307
|
+
if (js < minGameJsBytes) {
|
|
2308
|
+
return `inline JavaScript is ${js} bytes, need >= ${minGameJsBytes} \u2014 the page has no substantive game logic yet.`;
|
|
2303
2309
|
}
|
|
2304
2310
|
return "the page does not read as a working game yet \u2014 check the script and game loop.";
|
|
2305
2311
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GezelSDK } from './portable.js';
|
|
2
2
|
export { ArtifactEntry, AuthedHttpOpts, AuthedHttpResponse, DocumentEntry, FsEntry, FsStat, GezelSDKOptions, HttpRequestOpts, HttpResponse, IndexReadinessReport, InferredInput, InferredOutput, OneShotOpts, ScriptInit, ScriptResult, ScriptTransport, TaskNote, TaskNoteAuthor, TaskStep, WorkspaceIndexStatus, createGezelSDK, defineScript } from './portable.js';
|
|
3
|
-
export { G as GateScriptResult, I as InferInput, a as InferOutput, S as ScriptArrayOutput, b as ScriptBooleanInput, c as ScriptBooleanOutput, d as ScriptCapability, e as ScriptChoiceInput, f as ScriptChoiceOption, g as ScriptInputField, h as ScriptInputs, i as ScriptJsonInput, j as ScriptJsonOutput, k as ScriptMeta, l as ScriptNumberInput, m as ScriptNumberOutput, n as ScriptObjectOutput, o as ScriptOutputField, p as ScriptOutputs, q as ScriptRefInput, r as ScriptStringInput, s as ScriptStringOutput } from './types-
|
|
3
|
+
export { G as GateScriptResult, I as InferInput, a as InferOutput, S as ScriptArrayOutput, b as ScriptBooleanInput, c as ScriptBooleanOutput, d as ScriptCapability, e as ScriptChoiceInput, f as ScriptChoiceOption, g as ScriptInputField, h as ScriptInputs, i as ScriptJsonInput, j as ScriptJsonOutput, k as ScriptMeta, l as ScriptNumberInput, m as ScriptNumberOutput, n as ScriptObjectOutput, o as ScriptOutputField, p as ScriptOutputs, q as ScriptRefInput, r as ScriptStringInput, s as ScriptStringOutput } from './types-B03jHCAe.js';
|
|
4
4
|
|
|
5
5
|
declare const gezel: GezelSDK<Record<string, unknown>>;
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,10 @@ function createGezelSDK(rpc, options = {}) {
|
|
|
62
62
|
search: (query) => rpc.call("memory.search", { query }),
|
|
63
63
|
save: (text, meta) => rpc.call("memory.save", { text, meta })
|
|
64
64
|
},
|
|
65
|
+
reminder: {
|
|
66
|
+
set: (reminder) => rpc.call("reminder.set", reminder),
|
|
67
|
+
clear: () => rpc.call("reminder.clear", {})
|
|
68
|
+
},
|
|
65
69
|
llm: {
|
|
66
70
|
oneShot: (prompt, opts) => rpc.call("llm.oneShot", { prompt, opts })
|
|
67
71
|
},
|
package/dist/portable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as ScriptMeta, I as InferInput, a as InferOutput, h as ScriptInputs, p as ScriptOutputs } from './types-
|
|
2
|
-
export { G as GateScriptResult, S as ScriptArrayOutput, b as ScriptBooleanInput, c as ScriptBooleanOutput, d as ScriptCapability, e as ScriptChoiceInput, f as ScriptChoiceOption, g as ScriptInputField, i as ScriptJsonInput, j as ScriptJsonOutput, l as ScriptNumberInput, m as ScriptNumberOutput, n as ScriptObjectOutput, o as ScriptOutputField, q as ScriptRefInput, r as ScriptStringInput, s as ScriptStringOutput } from './types-
|
|
1
|
+
import { k as ScriptMeta, I as InferInput, a as InferOutput, h as ScriptInputs, p as ScriptOutputs } from './types-B03jHCAe.js';
|
|
2
|
+
export { G as GateScriptResult, S as ScriptArrayOutput, b as ScriptBooleanInput, c as ScriptBooleanOutput, d as ScriptCapability, e as ScriptChoiceInput, f as ScriptChoiceOption, g as ScriptInputField, i as ScriptJsonInput, j as ScriptJsonOutput, l as ScriptNumberInput, m as ScriptNumberOutput, n as ScriptObjectOutput, o as ScriptOutputField, q as ScriptRefInput, r as ScriptStringInput, s as ScriptStringOutput } from './types-B03jHCAe.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Script-SDK wire types for workspace-index status and readiness.
|
|
@@ -581,15 +581,46 @@ interface GezelSDK<TInput = Record<string, unknown>> {
|
|
|
581
581
|
*/
|
|
582
582
|
search(query: string): Promise<unknown[]>;
|
|
583
583
|
/**
|
|
584
|
-
* Save a memory
|
|
585
|
-
* skipped automatically.
|
|
584
|
+
* Save a memory. Near-duplicate text is skipped automatically.
|
|
586
585
|
* @param text - The fact to remember.
|
|
587
|
-
* @param meta - Optional metadata. A `kind` of `'fact'` |
|
|
588
|
-
* `'
|
|
589
|
-
*
|
|
586
|
+
* @param meta - Optional metadata. A `kind` of `'fact'` | `'decision'` |
|
|
587
|
+
* `'pref'` | `'status'` | `'correction'` | `'example'` categorizes the
|
|
588
|
+
* memory. By default it goes to the project's store; `scope: 'gezel'`
|
|
589
|
+
* saves it to the gezel whose chat called the script instead — how a
|
|
590
|
+
* scored activity decides what its gezel remembers (a learner's mistake
|
|
591
|
+
* as a `correction`, a strong answer as an `example`). Those entries need
|
|
592
|
+
* a `kind` and at most 200 characters. Write a correction with the wrong
|
|
593
|
+
* form first, in quotes (`Said "soy cansado"; it is "estoy cansado"`):
|
|
594
|
+
* when the person repeats it, recall says so. Other fields are ignored.
|
|
590
595
|
*/
|
|
591
596
|
save(text: string, meta?: Record<string, unknown>): Promise<void>;
|
|
592
597
|
};
|
|
598
|
+
/**
|
|
599
|
+
* **Reminder** — the project's one reminder, for a time this script
|
|
600
|
+
* computed from the project's own state (the next flashcard coming due),
|
|
601
|
+
* never a time picked for its own sake. The app turns it into a
|
|
602
|
+
* notification, within the person's daily allowance. Requires the
|
|
603
|
+
* `reminders` capability.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* await gezel.reminder.set({ at: nextDue.toISOString(), title: 'Cards are due', body: '4 cards to review' });
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
reminder: {
|
|
611
|
+
/**
|
|
612
|
+
* Set the project's reminder, replacing any earlier one.
|
|
613
|
+
* @param reminder - `at`: a future ISO date-time, at most 30 days ahead;
|
|
614
|
+
* `title`: up to 80 characters; `body`: up to 160.
|
|
615
|
+
*/
|
|
616
|
+
set(reminder: {
|
|
617
|
+
at: string;
|
|
618
|
+
title: string;
|
|
619
|
+
body?: string;
|
|
620
|
+
}): Promise<void>;
|
|
621
|
+
/** Clear the project's reminder (nothing is due). */
|
|
622
|
+
clear(): Promise<void>;
|
|
623
|
+
};
|
|
593
624
|
/**
|
|
594
625
|
* **LLM** — one-shot model completions. Requires the `llm` capability,
|
|
595
626
|
* and the project's AI engagement mode must not be `off` (otherwise
|
package/dist/portable.js
CHANGED
|
@@ -62,6 +62,10 @@ function createGezelSDK(rpc, options = {}) {
|
|
|
62
62
|
search: (query) => rpc.call("memory.search", { query }),
|
|
63
63
|
save: (text, meta) => rpc.call("memory.save", { text, meta })
|
|
64
64
|
},
|
|
65
|
+
reminder: {
|
|
66
|
+
set: (reminder) => rpc.call("reminder.set", reminder),
|
|
67
|
+
clear: () => rpc.call("reminder.clear", {})
|
|
68
|
+
},
|
|
65
69
|
llm: {
|
|
66
70
|
oneShot: (prompt, opts) => rpc.call("llm.oneShot", { prompt, opts })
|
|
67
71
|
},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `gezel.http.authed` additionally needs a `credential:<name>` entry
|
|
22
22
|
* (declared as a raw string in `requires`) naming each credential it uses.
|
|
23
23
|
*/
|
|
24
|
-
type ScriptCapability = 'llm' | 'network' | 'workspace.read' | 'workspace.write' | 'artifacts.read' | 'artifacts.write' | 'documents.read' | 'documents.write' | 'tasks.read' | 'tasks.write' | 'memory.read' | 'memory.write' | 'index.read' | 'index.refresh';
|
|
24
|
+
type ScriptCapability = 'llm' | 'network' | 'workspace.read' | 'workspace.write' | 'artifacts.read' | 'artifacts.write' | 'documents.read' | 'documents.write' | 'tasks.read' | 'tasks.write' | 'memory.read' | 'memory.write' | 'index.read' | 'index.refresh' | 'reminders';
|
|
25
25
|
/** A free-text string input field. */
|
|
26
26
|
interface ScriptStringInput {
|
|
27
27
|
type: 'string';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "SDK imported by scripts running in the Gezel sandbox. Exposes the `gezel` object and `defineScript` helper.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"!dist/**/*.map"
|
|
64
64
|
],
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@bendyline/gezel": "1.2.
|
|
66
|
+
"@bendyline/gezel": "1.2.4",
|
|
67
67
|
"tsup": "^8.5.1",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10"
|