@bendyline/gezel-sdk 1.1.11 → 1.1.12

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.js CHANGED
@@ -3395,6 +3395,12 @@ function mergeCorpusCoverageShards(batchesContent, shards, opts = {}) {
3395
3395
 
3396
3396
  // src/checks.ts
3397
3397
  function gateResult(ok, detail) {
3398
+ if (typeof ok !== "boolean") {
3399
+ return {
3400
+ decision: "reject",
3401
+ message: "gateResult expects a boolean first argument. Pass the check result\u2019s .ok value, or explicitly combine multiple checks into a boolean."
3402
+ };
3403
+ }
3398
3404
  return ok ? { decision: "approve", message: detail } : { decision: "reject", message: detail };
3399
3405
  }
3400
3406
  function workspaceFromGezel(g) {
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ function defineScript(meta) {
4
4
  }
5
5
  function createGezelSDK(rpc, options = {}) {
6
6
  let outputStamped = false;
7
- return {
7
+ return withMemberHints({
8
8
  get input() {
9
9
  return rpc.init.input ?? {};
10
10
  },
@@ -98,7 +98,30 @@ function createGezelSDK(rpc, options = {}) {
98
98
  script: {
99
99
  run: (name, input) => rpc.call("script.run", { name, input })
100
100
  }
101
- };
101
+ });
102
+ }
103
+ function withMemberHints(sdk) {
104
+ const members = sdk;
105
+ for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(sdk))) {
106
+ const value = descriptor.value;
107
+ if (value && typeof value === "object") {
108
+ members[name] = hintUnknownMembers(`gezel.${name}`, value);
109
+ }
110
+ }
111
+ return hintUnknownMembers("gezel", sdk);
112
+ }
113
+ var PROBED_KEYS = /* @__PURE__ */ new Set(["then", "toJSON", "asymmetricMatch", "nodeType", "$$typeof"]);
114
+ function hintUnknownMembers(path, target) {
115
+ return new Proxy(target, {
116
+ get(obj, key, receiver) {
117
+ if (typeof key !== "string" || key in obj || PROBED_KEYS.has(key)) {
118
+ return Reflect.get(obj, key, receiver);
119
+ }
120
+ throw new TypeError(
121
+ `${path}.${key} does not exist; ${path} has ${Object.keys(obj).join(", ")}`
122
+ );
123
+ }
124
+ });
102
125
  }
103
126
 
104
127
  // src/rpc.ts
package/dist/page.d.ts CHANGED
@@ -265,6 +265,14 @@ interface GezelPageTheme {
265
265
  /** Host UI state the page can mirror. */
266
266
  interface GezelPageUiApi {
267
267
  components: GezelPageComponents;
268
+ /** Fullscreen means the app's Output pane fills the Gezel window. */
269
+ readonly layout: {
270
+ readonly fullscreen: boolean;
271
+ readonly width: number;
272
+ readonly height: number;
273
+ };
274
+ /** Apply ui.layout at boot; subscribe to subsequent layout/size changes. */
275
+ onLayout(cb: (layout: GezelPageUiApi['layout']) => void): () => void;
268
276
  /** The current theme. Live — reflects the host's latest pushed value. */
269
277
  theme: GezelPageTheme;
270
278
  /**
@@ -314,8 +322,67 @@ interface GezelPageComponent<T> {
314
322
  update(options: Partial<T>): void;
315
323
  destroy(): void;
316
324
  }
325
+ interface GezelAppLayoutOptions {
326
+ /** Heading and useful context above the fullscreen conversation. */
327
+ title?: string;
328
+ description?: string;
329
+ /** False for a file-only app; otherwise chat appears when fullscreen. */
330
+ chat?: GezelChatOptions | false;
331
+ }
332
+ interface GezelActionField {
333
+ name: string;
334
+ label: string;
335
+ type?: 'text' | 'number' | 'date' | 'url';
336
+ required?: boolean;
337
+ multiline?: boolean;
338
+ options?: Array<string | {
339
+ value: string;
340
+ label: string;
341
+ }>;
342
+ placeholder?: string;
343
+ value?: string | number;
344
+ min?: number;
345
+ max?: number;
346
+ step?: number;
347
+ maxLength?: number;
348
+ /** Hide and omit this field unless another field has this value. */
349
+ when?: {
350
+ field: string;
351
+ equals: string;
352
+ };
353
+ }
354
+ interface GezelActionFormOptions {
355
+ title: string;
356
+ description?: string;
357
+ /** A declared page tool; ordinary validation and write policy still apply. */
358
+ tool: string;
359
+ fields: GezelActionField[];
360
+ submitLabel?: string;
361
+ successMessage?: string;
362
+ open?: boolean;
363
+ clearOnSave?: boolean;
364
+ /** Map form fields into the tool's declared input, for example one card into a cards array. */
365
+ mapInput?: (values: Record<string, string | number>) => Record<string, unknown>;
366
+ onSaved?: (result: GezelPageToolResult) => void | Promise<void>;
367
+ }
368
+ interface GezelCollectionFilterOptions {
369
+ container: string | HTMLElement;
370
+ selector: string;
371
+ label?: string;
372
+ placeholder?: string;
373
+ }
317
374
  interface GezelPageComponents {
318
375
  version: 1;
376
+ /** Searches rendered items, retaining their controls and refreshing after data updates. */
377
+ collectionFilter(target: string | HTMLElement, options: GezelCollectionFilterOptions): GezelPageComponent<GezelCollectionFilterOptions>;
378
+ /** Wrap existing content, retaining its DOM, and add a responsive fullscreen companion. */
379
+ appLayout(content: string | HTMLElement, options?: GezelAppLayoutOptions): GezelPageComponent<GezelAppLayoutOptions>;
380
+ /** Accessible, validated form invoking one declared action, with busy/error/success states. */
381
+ actionForm(target: string | HTMLElement, options: GezelActionFormOptions): GezelPageComponent<GezelActionFormOptions>;
382
+ /** Native, project-bound chat. No transcript or send API is exposed to page scripts. */
383
+ chat(target: string | HTMLElement, options?: GezelChatOptions): GezelPageComponent<GezelChatOptions> & {
384
+ ready: Promise<void>;
385
+ };
319
386
  fileCard(target: string | HTMLElement, options: GezelFileCardOptions): GezelPageComponent<GezelFileCardOptions>;
320
387
  fileAdder(target: string | HTMLElement, options: GezelFileAdderOptions): GezelPageComponent<GezelFileAdderOptions> & {
321
388
  refresh(): Promise<void>;
@@ -326,6 +393,68 @@ interface GezelPageComponents {
326
393
  reset(): void;
327
394
  };
328
395
  }
396
+ interface GezelChatOptions {
397
+ /** Exact recipient, or resolve gezelRole among this project's crew. Otherwise use its lead. */
398
+ gezelId?: string;
399
+ gezelRole?: string;
400
+ /** Defaults to true; also disables mention fan-out. */
401
+ lockRecipient?: boolean;
402
+ variant?: 'chat' | 'composer';
403
+ showAddress?: boolean;
404
+ showThreads?: boolean;
405
+ placeholder?: string;
406
+ /** Optional composer features are off by default in page components. */
407
+ attachments?: boolean;
408
+ dictation?: boolean;
409
+ promptAssist?: boolean;
410
+ expand?: boolean;
411
+ }
412
+ /** What a sample conversation's handlers may do in a standalone demo. */
413
+ interface GezelDemoConversationContext {
414
+ page: GezelPageInfo;
415
+ /** A snapshot of the page's sample data, as a live read returns fresh JSON. */
416
+ read(path: string, opts?: GezelPageReadOptions): Promise<unknown>;
417
+ /**
418
+ * Runs the page's demo handler for `tool` (or its `page_` alias), shows the
419
+ * step with `summary`, repaints watches, and highlights what changed.
420
+ */
421
+ invoke(tool: string, input?: Record<string, unknown>, summary?: string): Promise<unknown>;
422
+ /** Adds a companion line mid-turn. */
423
+ say(text: string): Promise<void>;
424
+ /** Replaces the suggestions without a reply; earlier wording may be offered again. */
425
+ suggest(next: string[]): void;
426
+ }
427
+ /** A reply: one message, several, or a message with fresh suggestions. */
428
+ type GezelDemoReply = string | string[] | {
429
+ reply: string | string[];
430
+ suggestions?: string[];
431
+ } | null | undefined;
432
+ /**
433
+ * The scripted companion a standalone demo shows where Gezel's chat would be.
434
+ * Replies never reach a model; the composer says they are scripted.
435
+ */
436
+ interface GezelDemoConversation {
437
+ /** A sample first name; live crew members are named when they are hired. */
438
+ name?: string;
439
+ /** The crew template's plain-English role. */
440
+ role?: string;
441
+ /** Image URL for the companion's avatar; an initial otherwise. */
442
+ avatar?: string;
443
+ greeting?: string;
444
+ suggestions?: string[];
445
+ /** Answer the person. Return null for the shared "sample requests only" reply. */
446
+ respond?(text: string, ctx: GezelDemoConversationContext): GezelDemoReply | Promise<GezelDemoReply>;
447
+ /** Keyed by page tool: the demo form of a manifest `reaction`. Return null to stay quiet. */
448
+ reactions?: Record<string, (input: Record<string, unknown>, output: unknown, ctx: GezelDemoConversationContext) => GezelDemoReply | Promise<GezelDemoReply>>;
449
+ }
450
+ /** Sample handlers the page passes to `makeDemoGezel` when no host injected `window.gezel`. */
451
+ interface GezelDemoOptions {
452
+ page?: Partial<Pick<GezelPageInfo, 'entry' | 'typeName' | 'params'>>;
453
+ tools?: Record<string, (input: Record<string, unknown>) => unknown>;
454
+ data?: Record<string, (opts: Record<string, unknown>) => unknown>;
455
+ existingPaths?: string[];
456
+ chat?: GezelDemoConversation;
457
+ }
329
458
  /**
330
459
  * The `window.gezel` object a served project-type page codes against.
331
460
  * Installed non-writable before any page script runs; absent entirely in
@@ -348,7 +477,9 @@ declare global {
348
477
  interface Window {
349
478
  /** Present when the page is served (or stubbed) with the gezel page API. */
350
479
  gezel?: GezelPageApi;
480
+ /** Present only where the shared demo bootstrap was injected. */
481
+ makeDemoGezel?: (options: GezelDemoOptions) => GezelPageApi;
351
482
  }
352
483
  }
353
484
 
354
- export { GEZEL_PAGE_API_VERSION, type GezelFileAdderOptions, type GezelFileCardOptions, type GezelImportResult, type GezelImportTarget, type GezelPageApi, type GezelPageComponent, type GezelPageComponents, type GezelPageDataApi, type GezelPageDirEntry, type GezelPageError, type GezelPageErrorCode, type GezelPageFile, type GezelPageInfo, type GezelPageMode, type GezelPageReadOptions, type GezelPageReadSource, type GezelPageSourceOptions, type GezelPageTable, type GezelPageTableQuery, type GezelPageTableSchema, type GezelPageTablesApi, type GezelPageTheme, type GezelPageToolReaction, type GezelPageToolResult, type GezelPageToolsApi, type GezelPageUiApi, type GezelPageWatchEvent, type GezelPageWatchOptions };
485
+ export { GEZEL_PAGE_API_VERSION, type GezelActionField, type GezelActionFormOptions, type GezelAppLayoutOptions, type GezelChatOptions, type GezelCollectionFilterOptions, type GezelDemoConversation, type GezelDemoConversationContext, type GezelDemoOptions, type GezelDemoReply, type GezelFileAdderOptions, type GezelFileCardOptions, type GezelImportResult, type GezelImportTarget, type GezelPageApi, type GezelPageComponent, type GezelPageComponents, type GezelPageDataApi, type GezelPageDirEntry, type GezelPageError, type GezelPageErrorCode, type GezelPageFile, type GezelPageInfo, type GezelPageMode, type GezelPageReadOptions, type GezelPageReadSource, type GezelPageSourceOptions, type GezelPageTable, type GezelPageTableQuery, type GezelPageTableSchema, type GezelPageTablesApi, type GezelPageTheme, type GezelPageToolReaction, type GezelPageToolResult, type GezelPageToolsApi, type GezelPageUiApi, type GezelPageWatchEvent, type GezelPageWatchOptions };
package/dist/portable.js CHANGED
@@ -4,7 +4,7 @@ function defineScript(meta) {
4
4
  }
5
5
  function createGezelSDK(rpc, options = {}) {
6
6
  let outputStamped = false;
7
- return {
7
+ return withMemberHints({
8
8
  get input() {
9
9
  return rpc.init.input ?? {};
10
10
  },
@@ -98,7 +98,30 @@ function createGezelSDK(rpc, options = {}) {
98
98
  script: {
99
99
  run: (name, input) => rpc.call("script.run", { name, input })
100
100
  }
101
- };
101
+ });
102
+ }
103
+ function withMemberHints(sdk) {
104
+ const members = sdk;
105
+ for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(sdk))) {
106
+ const value = descriptor.value;
107
+ if (value && typeof value === "object") {
108
+ members[name] = hintUnknownMembers(`gezel.${name}`, value);
109
+ }
110
+ }
111
+ return hintUnknownMembers("gezel", sdk);
112
+ }
113
+ var PROBED_KEYS = /* @__PURE__ */ new Set(["then", "toJSON", "asymmetricMatch", "nodeType", "$$typeof"]);
114
+ function hintUnknownMembers(path, target) {
115
+ return new Proxy(target, {
116
+ get(obj, key, receiver) {
117
+ if (typeof key !== "string" || key in obj || PROBED_KEYS.has(key)) {
118
+ return Reflect.get(obj, key, receiver);
119
+ }
120
+ throw new TypeError(
121
+ `${path}.${key} does not exist; ${path} has ${Object.keys(obj).join(", ")}`
122
+ );
123
+ }
124
+ });
102
125
  }
103
126
  export {
104
127
  createGezelSDK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-sdk",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "SDK for scripts that run in the Gezel sandbox: the gezel object and the 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.11",
66
+ "@bendyline/gezel": "1.2.12",
67
67
  "tsup": "^8.5.1",
68
68
  "typescript": "^6.0.3",
69
69
  "vitest": "^4.1.10"