@bendyline/gezel-sdk 1.1.2 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- import { G as GateScriptResult } from './types-rOo0kM35.js';
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
  /**
@@ -420,6 +403,13 @@ declare function citationsResolve(ws: WorkspaceLike, file: string, opts?: {
420
403
  minCitations?: number;
421
404
  corpus?: string[];
422
405
  knownPaths?: readonly string[];
406
+ /**
407
+ * Resolves a `knowledge://` citation against the installed catalogs.
408
+ * Without it those citations are counted as unchecked URLs; with it, one
409
+ * that names a catalog, document or passage that is not installed fails
410
+ * like a missing file.
411
+ */
412
+ resolveKnowledge?: (uri: string) => Promise<boolean>;
423
413
  }): Promise<CitationsResult>;
424
414
  /** Spec for {@link valuesSubsetOf}. */
425
415
  interface ValuesSubsetSpec {
@@ -750,7 +740,7 @@ type ExplainableSniff = 'html-complete' | 'html-game' | 'nonempty' | 'json-valid
750
740
  * that actually passes, a generic line is returned rather than lying
751
741
  * about a defect.
752
742
  */
753
- declare function explainSniff(name: ExplainableSniff, content: string): string;
743
+ declare function explainSniff(name: ExplainableSniff, content: string, minGameJsBytes?: number): string;
754
744
 
755
745
  /**
756
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 htmlGameSniff(html, minJsBytes = 400) {
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 hasSurface = hasRenderTarget || hasFrameLoop;
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 hasSurface && scriptClosed && jsSubstantial;
113
+ return hasHtmlGameSurface(html) && scriptClosed && jsSubstantial;
105
114
  }
106
115
 
107
116
  // ../core/src/checks/records.ts
@@ -1114,6 +1123,11 @@ async function citationsResolve(ws, file, opts = {}) {
1114
1123
  const urls = [];
1115
1124
  const forgiven = [];
1116
1125
  for (const c of cites) {
1126
+ if (opts.resolveKnowledge && /^knowledge:\/\//i.test(c)) {
1127
+ if (await opts.resolveKnowledge(c)) resolved.push(c);
1128
+ else unresolved.push(c);
1129
+ continue;
1130
+ }
1117
1131
  if (/^[a-z][\w+.-]*:\/\//i.test(c) || c.startsWith("mailto:")) {
1118
1132
  urls.push(c);
1119
1133
  if (corpus && !corpus.has(c.toLowerCase())) unresolved.push(c);
@@ -1142,7 +1156,7 @@ async function citationsResolve(ws, file, opts = {}) {
1142
1156
  const listed = unresolved.slice(0, 5).map((u) => `\`${u}\``).join(", ");
1143
1157
  return {
1144
1158
  ok: false,
1145
- detail: `${file} cites ${unresolved.length} source(s) that do not exist: ${listed}${unresolved.length > 5 ? ", \u2026" : ""} \u2014 every cited path must resolve to a real file in the workspace${corpus ? "/corpus" : ""} (no fabricated citations).`,
1159
+ detail: `${file} cites ${unresolved.length} source(s) that do not exist: ${listed}${unresolved.length > 5 ? ", \u2026" : ""} \u2014 every cited path must resolve to a real file in the workspace${corpus ? "/corpus" : ""}${unresolved.some((u) => /^knowledge:\/\//i.test(u)) ? ", and every knowledge:// citation to a passage in an installed catalog (copy the URI from a search result; do not compose one)" : ""} (no fabricated citations).`,
1146
1160
  resolved,
1147
1161
  unresolved,
1148
1162
  urls,
@@ -2265,7 +2279,7 @@ async function markdownHeadingsMatch(ws, file, outlineFile, outlineWs = ws) {
2265
2279
  }
2266
2280
 
2267
2281
  // ../core/src/checks/sniff-explain.ts
2268
- function explainSniff(name, content) {
2282
+ function explainSniff(name, content, minGameJsBytes = 400) {
2269
2283
  switch (name) {
2270
2284
  case "html-complete": {
2271
2285
  const scripts = detectUnclosedScript(content);
@@ -2279,22 +2293,19 @@ function explainSniff(name, content) {
2279
2293
  return "the document is incomplete \u2014 finish and close it.";
2280
2294
  }
2281
2295
  case "html-game": {
2282
- const lower = content.toLowerCase();
2283
- const hasRenderTarget = /<canvas\b/.test(lower) || /<svg\b/.test(lower);
2284
- 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);
2285
- if (!hasRenderTarget && !hasFrameLoop) {
2286
- return "no render surface (<canvas>/<svg>) and no frame loop (requestAnimationFrame / setInterval / a tick()/update() function) \u2014 add the game loop.";
2287
- }
2288
2296
  const scripts = detectUnclosedScript(content);
2289
- if (scripts.opens === 0) {
2290
- return "no <script> block \u2014 the page has no game logic; add the inline script.";
2291
- }
2292
2297
  if (scripts.unclosed) {
2293
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.`;
2294
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
+ }
2295
2306
  const js = inlineJsBytes(content);
2296
- if (js < 400) {
2297
- return `inline JavaScript is ${js} bytes, need >= 400 \u2014 the page has no substantive game logic yet.`;
2307
+ if (js < minGameJsBytes) {
2308
+ return `inline JavaScript is ${js} bytes, need >= ${minGameJsBytes} \u2014 the page has no substantive game logic yet.`;
2298
2309
  }
2299
2310
  return "the page does not read as a working game yet \u2014 check the script and game loop.";
2300
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-rOo0kM35.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-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
  },
@@ -1,5 +1,5 @@
1
- import { k as ScriptMeta, I as InferInput, a as InferOutput, h as ScriptInputs, p as ScriptOutputs } from './types-rOo0kM35.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-rOo0kM35.js';
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 to the project's store. Near-duplicate text is
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
- * `'decision'` | `'pref'` | `'status'` categorizes the memory;
589
- * other fields are ignored.
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.2",
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.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"