@punica/editor 1.10.7 → 1.10.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/editor",
3
- "version": "1.10.7",
3
+ "version": "1.10.9",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
6
  "type": "module",
@@ -473,6 +473,68 @@ declare module 'punica' {
473
473
 
474
474
  export const sessions: AiSessionsApi;
475
475
 
476
+ /**
477
+ * One capability's record in the tool-usage history.
478
+ *
479
+ * Four fields, and the list is the whole contract rather than a
480
+ * starting point: a capability id, how often it ran, how often that
481
+ * worked, and when it last did. There is deliberately nowhere here for
482
+ * a prompt, an argument or a path.
483
+ */
484
+ export interface ToolUsageEntry {
485
+ capabilityId: string;
486
+ calls: number;
487
+ /** Successful calls; `calls - ok` failed. */
488
+ ok: number;
489
+ /** Epoch ms of the most recent call. */
490
+ last: number;
491
+ /**
492
+ * The weight tool selection currently gives this capability, in
493
+ * [0, 1): recent use, saturating volume and success rate multiplied
494
+ * together. Reported alongside the raw counts because the counts on
495
+ * their own do not explain a ranking.
496
+ */
497
+ prior: number;
498
+ }
499
+
500
+ /**
501
+ * Persistence seam for the usage history. Host-injectable in the same
502
+ * shape as the approval and session stores, but asynchronous, because
503
+ * both of its call sites already are and a synchronous store would
504
+ * silently rank as though the user were new whenever a read landed
505
+ * before hydration.
506
+ *
507
+ * Every method is best-effort by contract: the prior is an
508
+ * optimization, and a store that fails must degrade to ranking without
509
+ * history rather than fail a run.
510
+ */
511
+ export interface ToolUsageStore {
512
+ read(): Promise<Record<string, { calls: number; ok: number; last: number }>>;
513
+ record(capabilityId: string, ok: boolean, atMs: number): Promise<void>;
514
+ forget(): Promise<void>;
515
+ }
516
+
517
+ /**
518
+ * `punica.kernel.AI.toolUsage` — what tool selection learned from this
519
+ * installation, and the switch that forgets it.
520
+ *
521
+ * Tool selection blends a capability's own call history into its
522
+ * ranking, so the product gets better at choosing the longer it is
523
+ * used. That is invisible by construction, which is the reason this
524
+ * surface exists: a person can read exactly what is stored and empty it
525
+ * in one call.
526
+ */
527
+ export interface ToolUsageApi {
528
+ /** Everything known, strongest prior first. */
529
+ list(): Promise<ToolUsageEntry[]>;
530
+ /** Erase the history. Ranking returns to a fresh install's. */
531
+ forget(): Promise<void>;
532
+ /** Host injection; `undefined` restores the substrate default. */
533
+ setStore(store: ToolUsageStore | undefined): void;
534
+ }
535
+
536
+ export const toolUsage: ToolUsageApi;
537
+
476
538
  export interface AiApi {
477
539
  initialize(): void;
478
540
  /**