@guuey/agent-client 0.16.8 → 0.16.10

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { parseSseEvents, extractAssistantText, reduceAssistantText, stringField, parseLinkRequest, type ParsedSseEvent, } from "./sse.js";
2
2
  export { dismissLinkPrompt } from "./link-prompt.js";
3
3
  export { invokeTurn, toInvokeUrl, type InvokeTurnEvent } from "./invoke-turn.js";
4
- export { createHitlAnswerRelay, type CreateHitlAnswerRelayOptions, type HitlAnswerRelayResult, createUiActionRelay, type CreateUiActionRelayOptions, createUiResourceReader, type CreateUiResourceReaderOptions, createWebAdapters, localStorageThreadStore, webGenerateId, type CreateWebAdaptersOptions, } from "./web-adapters.js";
4
+ export { createHitlAnswerRelay, type CreateHitlAnswerRelayOptions, type HitlAnswerRelayResult, createUiActionRelay, type CreateUiActionRelayOptions, createUiResourceReader, type CreateUiResourceReaderOptions, createWebAdapters, deleteThread, type DeleteThreadOptions, type DeleteThreadResult, localStorageThreadStore, webGenerateId, type CreateWebAdaptersOptions, } from "./web-adapters.js";
5
5
  export { fetchStreamTransport, sendableGuestSecret, GUEST_HEADER, withActivityObserver, type FetchStreamTransportOptions, } from "./transport.js";
6
6
  export { withSaturationRetry, withColdStartRetry, parseRetryAfterSeconds, type SaturationRetryOptions, type ColdStartRetryOptions, } from "./saturation-retry.js";
7
7
  export { AgentResponseError } from "./errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,eAAe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D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM7D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,YAAY,EACV,OAAO,EACP,cAAc,EACd,SAAS,EACT,OAAO,EAIP,oBAAoB,EACpB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { dismissLinkPrompt } from "./link-prompt.js";
3
3
  // One agent turn as a pure async generator — the wire walk `useAgentInvoke`
4
4
  // wraps, for hosts that drive their own turn state machine (guuey#186 G5).
5
5
  export { invokeTurn, toInvokeUrl } from "./invoke-turn.js";
6
- export { createHitlAnswerRelay, createUiActionRelay, createUiResourceReader, createWebAdapters, localStorageThreadStore, webGenerateId, } from "./web-adapters.js";
6
+ export { createHitlAnswerRelay, createUiActionRelay, createUiResourceReader, createWebAdapters, deleteThread, localStorageThreadStore, webGenerateId, } from "./web-adapters.js";
7
7
  // The invoke transport + guest-identity wire pieces, in their own
8
8
  // mcp-apps-host-free module. Consumers that want ONLY this graph (no
9
9
  // host-role card layer riding along) import `@guuey/agent-client/transport`
@@ -277,4 +277,45 @@ export type HitlAnswerRelayResult = {
277
277
  * `hitl.ask` the runtime emits is answered through this same door.
278
278
  */
279
279
  export declare function createHitlAnswerRelay(options: CreateHitlAnswerRelayOptions): (answer: AgHitlAnswer) => Promise<HitlAnswerRelayResult>;
280
+ /** Options for {@link deleteThread} — the same credential surface as the sibling platform doors. */
281
+ export interface DeleteThreadOptions {
282
+ /** The guuey public API base (`…/v1`) — the same base the transcript reads use. */
283
+ apiBaseUrl: string;
284
+ /** The thread to erase. Must be the id the SAME identity created. */
285
+ threadId: string;
286
+ /** Signed-in bearer — wins over the guest secret (same rule as the transport). */
287
+ getAccessToken?: (opts?: {
288
+ forceRefresh?: boolean;
289
+ }) => Promise<string | null>;
290
+ /**
291
+ * Caller-owned anonymous guest secret (widget / guest chat). Callers that
292
+ * rotate the secret as part of a clear MUST capture this value BEFORE
293
+ * rotating — the delete authenticates as the identity that OWNS the
294
+ * thread, and a post-rotation secret is a stranger to it (403).
295
+ */
296
+ guestSecret?: string | null;
297
+ /** Injectable for tests. */
298
+ fetchImpl?: typeof fetch;
299
+ }
300
+ /**
301
+ * The delete door's outcome, collapsed to what a caller can act on:
302
+ * `"deleted"` — the server no longer holds the thread (200, or the
303
+ * contract's 404-idempotent arm: the row is already gone); `"denied"` —
304
+ * the credential did not own the thread (401/403; guuey#526's
305
+ * unlinkability fallback applies: clear locally anyway, surface nothing
306
+ * louder than a debug line); `"failed"` — transport or server failure
307
+ * (the thread may still exist server-side).
308
+ */
309
+ export type DeleteThreadResult = "deleted" | "denied" | "failed";
310
+ /**
311
+ * `DELETE /v1/threads/:threadId` — the guest-erasure door (guuey#526).
312
+ *
313
+ * Real, child-first server-side deletion (messages → fold snapshot →
314
+ * thread row last; replayable on partial failure — the server half's
315
+ * contract, c6056b679). Identity is EXACTLY the transcript read's:
316
+ * one carrier per call, bearer → guest header → else cookie credentials,
317
+ * with the reader's single forceRefresh retry on a 401 bearer. Never
318
+ * throws — every failure collapses into the result union.
319
+ */
320
+ export declare function deleteThread(options: DeleteThreadOptions): Promise<DeleteThreadResult>;
280
321
  //# sourceMappingURL=web-adapters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-adapters.d.ts","sourceRoot":"","sources":["../src/web-adapters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAA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}
@@ -473,3 +473,59 @@ export function createHitlAnswerRelay(options) {
473
473
  };
474
474
  };
475
475
  }
476
+ /**
477
+ * `DELETE /v1/threads/:threadId` — the guest-erasure door (guuey#526).
478
+ *
479
+ * Real, child-first server-side deletion (messages → fold snapshot →
480
+ * thread row last; replayable on partial failure — the server half's
481
+ * contract, c6056b679). Identity is EXACTLY the transcript read's:
482
+ * one carrier per call, bearer → guest header → else cookie credentials,
483
+ * with the reader's single forceRefresh retry on a 401 bearer. Never
484
+ * throws — every failure collapses into the result union.
485
+ */
486
+ export async function deleteThread(options) {
487
+ const fetchImpl = options.fetchImpl ?? fetch;
488
+ const requestUrl = `${options.apiBaseUrl}/threads/${encodeURIComponent(options.threadId)}`;
489
+ const headers = {};
490
+ const init = { method: "DELETE", headers };
491
+ const token = options.getAccessToken ? await options.getAccessToken().catch(() => null) : null;
492
+ const guest = sendableGuestSecret(options.guestSecret);
493
+ if (token) {
494
+ headers["authorization"] = `Bearer ${token}`;
495
+ }
496
+ else if (guest) {
497
+ headers[GUEST_HEADER] = guest;
498
+ }
499
+ else {
500
+ init.credentials = "include";
501
+ }
502
+ let res;
503
+ try {
504
+ res = await fetchImpl(requestUrl, init);
505
+ }
506
+ catch {
507
+ return "failed";
508
+ }
509
+ if (res.status === 401 && options.getAccessToken) {
510
+ const fresh = await options.getAccessToken({ forceRefresh: true }).catch(() => null);
511
+ if (fresh) {
512
+ try {
513
+ res = await fetchImpl(requestUrl, {
514
+ method: "DELETE",
515
+ headers: { authorization: `Bearer ${fresh}` },
516
+ });
517
+ }
518
+ catch {
519
+ return "failed";
520
+ }
521
+ }
522
+ }
523
+ // 404 is SUCCESS by contract: the row is gone (a repeat delete, or a
524
+ // never-persisted thread). Treating it as failure would make the honest
525
+ // "already erased" case look like an error to every caller.
526
+ if (res.ok || res.status === 404)
527
+ return "deleted";
528
+ if (res.status === 401 || res.status === 403)
529
+ return "denied";
530
+ return "failed";
531
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guuey/agent-client",
3
- "version": "0.16.8",
3
+ "version": "0.16.10",
4
4
  "description": "Client SDK for Guuey's agent runtime: the `useAgentInvoke` React hook + pure SSE helpers that speak the /agent/invoke streaming contract, plus the paginated thread-history read plane. Host adapters (storage / id / transport) are injected, so it runs on web (Next) and React Native alike.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@silverprotocol/core": "0.5.3",
38
- "@guuey/mcp-apps-host": "0.16.8"
38
+ "@guuey/mcp-apps-host": "0.16.10"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=18"
package/src/index.ts CHANGED
@@ -19,6 +19,9 @@ export {
19
19
  createUiResourceReader,
20
20
  type CreateUiResourceReaderOptions,
21
21
  createWebAdapters,
22
+ deleteThread,
23
+ type DeleteThreadOptions,
24
+ type DeleteThreadResult,
22
25
  localStorageThreadStore,
23
26
  webGenerateId,
24
27
  type CreateWebAdaptersOptions,
@@ -686,3 +686,84 @@ export function createHitlAnswerRelay(
686
686
  };
687
687
  };
688
688
  }
689
+
690
+ /** Options for {@link deleteThread} — the same credential surface as the sibling platform doors. */
691
+ export interface DeleteThreadOptions {
692
+ /** The guuey public API base (`…/v1`) — the same base the transcript reads use. */
693
+ apiBaseUrl: string;
694
+ /** The thread to erase. Must be the id the SAME identity created. */
695
+ threadId: string;
696
+ /** Signed-in bearer — wins over the guest secret (same rule as the transport). */
697
+ getAccessToken?: (opts?: { forceRefresh?: boolean }) => Promise<string | null>;
698
+ /**
699
+ * Caller-owned anonymous guest secret (widget / guest chat). Callers that
700
+ * rotate the secret as part of a clear MUST capture this value BEFORE
701
+ * rotating — the delete authenticates as the identity that OWNS the
702
+ * thread, and a post-rotation secret is a stranger to it (403).
703
+ */
704
+ guestSecret?: string | null;
705
+ /** Injectable for tests. */
706
+ fetchImpl?: typeof fetch;
707
+ }
708
+
709
+ /**
710
+ * The delete door's outcome, collapsed to what a caller can act on:
711
+ * `"deleted"` — the server no longer holds the thread (200, or the
712
+ * contract's 404-idempotent arm: the row is already gone); `"denied"` —
713
+ * the credential did not own the thread (401/403; guuey#526's
714
+ * unlinkability fallback applies: clear locally anyway, surface nothing
715
+ * louder than a debug line); `"failed"` — transport or server failure
716
+ * (the thread may still exist server-side).
717
+ */
718
+ export type DeleteThreadResult = "deleted" | "denied" | "failed";
719
+
720
+ /**
721
+ * `DELETE /v1/threads/:threadId` — the guest-erasure door (guuey#526).
722
+ *
723
+ * Real, child-first server-side deletion (messages → fold snapshot →
724
+ * thread row last; replayable on partial failure — the server half's
725
+ * contract, c6056b679). Identity is EXACTLY the transcript read's:
726
+ * one carrier per call, bearer → guest header → else cookie credentials,
727
+ * with the reader's single forceRefresh retry on a 401 bearer. Never
728
+ * throws — every failure collapses into the result union.
729
+ */
730
+ export async function deleteThread(options: DeleteThreadOptions): Promise<DeleteThreadResult> {
731
+ const fetchImpl = options.fetchImpl ?? fetch;
732
+ const requestUrl = `${options.apiBaseUrl}/threads/${encodeURIComponent(options.threadId)}`;
733
+ const headers: Record<string, string> = {};
734
+ const init: RequestInit = { method: "DELETE", headers };
735
+ const token = options.getAccessToken ? await options.getAccessToken().catch(() => null) : null;
736
+ const guest = sendableGuestSecret(options.guestSecret);
737
+ if (token) {
738
+ headers["authorization"] = `Bearer ${token}`;
739
+ } else if (guest) {
740
+ headers[GUEST_HEADER] = guest;
741
+ } else {
742
+ init.credentials = "include";
743
+ }
744
+ let res: Response;
745
+ try {
746
+ res = await fetchImpl(requestUrl, init);
747
+ } catch {
748
+ return "failed";
749
+ }
750
+ if (res.status === 401 && options.getAccessToken) {
751
+ const fresh = await options.getAccessToken({ forceRefresh: true }).catch(() => null);
752
+ if (fresh) {
753
+ try {
754
+ res = await fetchImpl(requestUrl, {
755
+ method: "DELETE",
756
+ headers: { authorization: `Bearer ${fresh}` },
757
+ });
758
+ } catch {
759
+ return "failed";
760
+ }
761
+ }
762
+ }
763
+ // 404 is SUCCESS by contract: the row is gone (a repeat delete, or a
764
+ // never-persisted thread). Treating it as failure would make the honest
765
+ // "already erased" case look like an error to every caller.
766
+ if (res.ok || res.status === 404) return "deleted";
767
+ if (res.status === 401 || res.status === 403) return "denied";
768
+ return "failed";
769
+ }