@simpleplatform/sdk 2.4.0 → 2.4.2

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 CHANGED
@@ -308,6 +308,63 @@ yet; attach its handle through the workflow that owns the record.
308
308
 
309
309
  ## API Documentation
310
310
 
311
+ ### Describing an Action
312
+
313
+ What an action is, and when to reach for it, is written where the code is — in
314
+ the JSDoc comment above the handler, the same comment that carries its
315
+ description:
316
+
317
+ ```typescript
318
+ /**
319
+ * Close a duplicate lead and point it at the record that survives.
320
+ *
321
+ * The surviving lead keeps its activity; the duplicate is marked closed and
322
+ * linked to it, so a later report still reaches both records.
323
+ *
324
+ * @tool
325
+ * @shortdesc Close a duplicate lead, pointing it at the surviving record.
326
+ * @usewhen A lead is a duplicate of one already in the system.
327
+ * @usewhen Two leads share a contact and one should be retired.
328
+ */
329
+ simple.Handle(async (request) => {
330
+ // ...
331
+ })
332
+ ```
333
+
334
+ | Tag | Shape | What it says |
335
+ | --------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
336
+ | `@tool` | bare, no value | This action can be reached as a tool |
337
+ | `@shortdesc` | one line, up to 300 characters, written once | What this is, read in a listing of tools |
338
+ | `@usewhen` | one line, up to 100 characters, up to ten times | One occasion for reaching for this rather than something else |
339
+ | `@parallelsafe` | bare, no value, only alongside `@tool` | This tool changes no stored data and sends nothing, so it may run at the same time as the other parallel-safe calls next to it in a batch |
340
+
341
+ `@parallelsafe` is a claim you make about your own action; the platform does
342
+ not verify it. It changes only which calls of a batch may overlap — consecutive
343
+ parallel-safe calls may run at the same time, and every other call still runs
344
+ alone, in the order asked. It never changes whether a failed call is retried,
345
+ nor the platform's assumption that a failed call may have changed stored data.
346
+ The build refuses it without `@tool`, with a value, or written twice. Write it
347
+ only when the action is read-only:
348
+
349
+ ```typescript
350
+ /**
351
+ * Look up a lead's open activity.
352
+ *
353
+ * @tool
354
+ * @shortdesc Look up a lead's open activity.
355
+ * @usewhen A caller wants a lead's current open activity.
356
+ * @parallelsafe
357
+ */
358
+ simple.Handle(async (request) => {
359
+ // reads only — no writes, no outbound calls
360
+ })
361
+ ```
362
+
363
+ The prose above the tags is the full description, and stays exactly as
364
+ written. Each tag is declared in `tsdoc.json` (`{"tagName": "@parallelsafe",
365
+ "syntaxKind": "modifier"}` alongside `@tool`, `@shortdesc` and `@usewhen`), so
366
+ an editor with TSDoc support recognizes it instead of flagging it as unknown.
367
+
311
368
  ### AI Module
312
369
 
313
370
  The AI module provides powerful capabilities for working with unstructured data.
@@ -387,9 +444,9 @@ console.log(result.data.participants) // ["Customer", "Support Agent"]
387
444
  Read the pages of a PDF that have no usable text of their own — scans,
388
445
  image-only exhibits — from their images. Each such page is transcribed once,
389
446
  and it is the same transcription an `extract` or `summarize` that asks for text
390
- is given in the page's place, so a quote on an image page can be checked
391
- against the text the answer was built on. Pages with a readable text layer are
392
- not returned.
447
+ is given in the page's place, so the text you hold for an image page is exactly
448
+ the text the answer was built on. Pages with a readable text layer are not
449
+ returned.
393
450
 
394
451
  ```typescript
395
452
  import { transcribePages } from '@simpleplatform/sdk/ai'
@@ -406,7 +463,7 @@ for (const page of data.pages) {
406
463
  continue
407
464
  }
408
465
 
409
- console.log(page.page, page.text.includes(quote))
466
+ console.log(page.page, page.text)
410
467
  }
411
468
  ```
412
469
 
package/dist/ai.d.ts CHANGED
@@ -400,10 +400,9 @@ export declare function transcribe(input: DocumentHandle, options: AITranscribeO
400
400
  * image-only exhibits, text that reads as noise — from their images.
401
401
  *
402
402
  * Every such page is read once, and it is the same transcription an `extract`
403
- * or `summarize` that asked for text is given in the page's place, so a caller
404
- * can check that a quote on an image page is really there by looking for it in
405
- * the text the answer was built on. Pages the platform reads as text are
406
- * neither read nor returned.
403
+ * or `summarize` that asked for text is given in the page's place, so the text
404
+ * a caller holds for an image page is exactly the text the answer was built on.
405
+ * Pages the platform reads as text are neither read nor returned.
407
406
  *
408
407
  * A page is not transcribed a second time to check the first: that would be
409
408
  * the same model reading the same image again, doubling the cost of every
@@ -430,10 +429,11 @@ export declare function transcribe(input: DocumentHandle, options: AITranscribeO
430
429
  * context,
431
430
  * )
432
431
  *
432
+ * const pages = new Map<number, string>()
433
433
  * for (const page of data.pages) {
434
434
  * if ('error' in page)
435
435
  * continue
436
- * const quoted = page.text.includes(quote)
436
+ * pages.set(page.page, page.text) // the text the answer was built on
437
437
  * }
438
438
  */
439
439
  export declare function transcribePages(document: AITranscribePagesInput, options: AITranscribePagesOptions, context: Context): Promise<AITranscriptionResult>;
package/dist/ai.js CHANGED
@@ -322,10 +322,9 @@ export async function transcribe(input, options, context) {
322
322
  * image-only exhibits, text that reads as noise — from their images.
323
323
  *
324
324
  * Every such page is read once, and it is the same transcription an `extract`
325
- * or `summarize` that asked for text is given in the page's place, so a caller
326
- * can check that a quote on an image page is really there by looking for it in
327
- * the text the answer was built on. Pages the platform reads as text are
328
- * neither read nor returned.
325
+ * or `summarize` that asked for text is given in the page's place, so the text
326
+ * a caller holds for an image page is exactly the text the answer was built on.
327
+ * Pages the platform reads as text are neither read nor returned.
329
328
  *
330
329
  * A page is not transcribed a second time to check the first: that would be
331
330
  * the same model reading the same image again, doubling the cost of every
@@ -352,10 +351,11 @@ export async function transcribe(input, options, context) {
352
351
  * context,
353
352
  * )
354
353
  *
354
+ * const pages = new Map<number, string>()
355
355
  * for (const page of data.pages) {
356
356
  * if ('error' in page)
357
357
  * continue
358
- * const quoted = page.text.includes(quote)
358
+ * pages.set(page.page, page.text) // the text the answer was built on
359
359
  * }
360
360
  */
361
361
  export async function transcribePages(document, options, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleplatform/sdk",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Simple Platform Typescript SDK",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.simple.dev",