@mindstudio-ai/agent 0.1.100 → 0.1.102

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
@@ -428,6 +428,62 @@ roles. Pass `onEvent` to stream progress (text chunks, tool calls, the final `do
428
428
  > `outputSchema` typing uses a `const` type parameter — consuming projects need
429
429
  > TypeScript 5.0+.
430
430
 
431
+ ## Jewels
432
+
433
+ A jewel is an agentic shadow companion for an app method — `foo.jewel.ts` beside `foo.ts`,
434
+ built with `defineJewel(method, { subject, propose, grade? })`. It proposes the method
435
+ input a careful operator would submit (or abstains with `input: null`), gets graded
436
+ against what a human actually did, and climbs an autonomy ladder (`shadow` → `approve` →
437
+ `auto`) declared in the app manifest.
438
+
439
+ Attach the deciding task's transcript to the proposal: `return { input, reasoning,
440
+ trace: task.traceId }` (an array for escalation chains). The platform records
441
+ jewel-run transcripts server-side per turn; the attached id preserves the full model
442
+ transcript with the pair — the training row and the audit trail. A custom `grade`'s
443
+ verdict may attach its judge's `trace` the same way.
444
+
445
+ For decision moments the app detects itself (an ingest branch that lands a row in a
446
+ pending state), hand the moment to the jewels from backend code:
447
+
448
+ ```ts
449
+ mindstudio.waitUntil((async () => {
450
+ const merge = await mindstudio.jewels.propose(
451
+ 'merge-issues', { sourceId: issue.id }, { idempotencyKey: issue.id });
452
+ if (merge.outcome !== 'committed') {
453
+ await mindstudio.jewels.propose(
454
+ 'triage-issue', { issueId: issue.id }, { idempotencyKey: issue.id });
455
+ }
456
+ })());
457
+ ```
458
+
459
+ The platform routes each proposal by the method's autonomy — `recorded` (shadow),
460
+ `queued` (approve), `committed` (auto: the method ran) — and `idempotencyKey` has Stripe
461
+ semantics (a replayed key returns the original outcome, so webhook retries are safe).
462
+ Backend/managed contexts only.
463
+
464
+ For `approve`-mode methods, build the review inbox natively in the app with
465
+ `jewels.queue`:
466
+
467
+ ```ts
468
+ // Backend method — gate with the app's own reviewer role.
469
+ export async function listDraftReplies() {
470
+ auth.requireRole('support_lead');
471
+ return mindstudio.jewels.queue.list({ methodId: 'send-reply' });
472
+ }
473
+
474
+ export async function reviewDraft({ itemId, action, edited }) {
475
+ auth.requireRole('support_lead');
476
+ return mindstudio.jewels.queue.resolve(itemId, {
477
+ action, // 'approve' | 'dismiss'
478
+ ...(edited ? { input: edited } : {}), // an edit is captured with the pair
479
+ });
480
+ }
481
+ ```
482
+
483
+ Approving **applies the target method as the signed-in reviewer** — the effect belongs
484
+ to the human who clicked, and the target method's own auth checks are the real gate on
485
+ who may approve. Unresolved items expire at the method's `attributionWindow`.
486
+
431
487
  ## Thread persistence
432
488
 
433
489
  Steps execute within threads. Pass `$threadId` and `$appId` from a previous call to maintain state:
@@ -585,6 +641,10 @@ import type {
585
641
  JsonSchema,
586
642
  JsonObjectSchema,
587
643
  FromSchema,
644
+ JewelConfig,
645
+ JewelPairRecord,
646
+ JewelProposeOutcome,
647
+ JewelProposeResult,
588
648
  } from '@mindstudio-ai/agent';
589
649
  ```
590
650