@mindstudio-ai/agent 0.1.100 → 0.1.101

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,56 @@ 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
+ For decision moments the app detects itself (an ingest branch that lands a row in a
440
+ pending state), hand the moment to the jewels from backend code:
441
+
442
+ ```ts
443
+ mindstudio.waitUntil((async () => {
444
+ const merge = await mindstudio.jewels.propose(
445
+ 'merge-issues', { sourceId: issue.id }, { idempotencyKey: issue.id });
446
+ if (merge.outcome !== 'committed') {
447
+ await mindstudio.jewels.propose(
448
+ 'triage-issue', { issueId: issue.id }, { idempotencyKey: issue.id });
449
+ }
450
+ })());
451
+ ```
452
+
453
+ The platform routes each proposal by the method's autonomy — `recorded` (shadow),
454
+ `queued` (approve), `committed` (auto: the method ran) — and `idempotencyKey` has Stripe
455
+ semantics (a replayed key returns the original outcome, so webhook retries are safe).
456
+ Backend/managed contexts only.
457
+
458
+ For `approve`-mode methods, build the review inbox natively in the app with
459
+ `jewels.queue`:
460
+
461
+ ```ts
462
+ // Backend method — gate with the app's own reviewer role.
463
+ export async function listDraftReplies() {
464
+ auth.requireRole('support_lead');
465
+ return mindstudio.jewels.queue.list({ methodId: 'send-reply' });
466
+ }
467
+
468
+ export async function reviewDraft({ itemId, action, edited }) {
469
+ auth.requireRole('support_lead');
470
+ return mindstudio.jewels.queue.resolve(itemId, {
471
+ action, // 'approve' | 'dismiss'
472
+ ...(edited ? { input: edited } : {}), // an edit is captured with the pair
473
+ });
474
+ }
475
+ ```
476
+
477
+ Approving **applies the target method as the signed-in reviewer** — the effect belongs
478
+ to the human who clicked, and the target method's own auth checks are the real gate on
479
+ who may approve. Unresolved items expire at the method's `attributionWindow`.
480
+
431
481
  ## Thread persistence
432
482
 
433
483
  Steps execute within threads. Pass `$threadId` and `$appId` from a previous call to maintain state:
@@ -585,6 +635,10 @@ import type {
585
635
  JsonSchema,
586
636
  JsonObjectSchema,
587
637
  FromSchema,
638
+ JewelConfig,
639
+ JewelPairRecord,
640
+ JewelProposeOutcome,
641
+ JewelProposeResult,
588
642
  } from '@mindstudio-ai/agent';
589
643
  ```
590
644