@ouispec/agent-react 0.1.0

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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/annotations/AnnotationRegistry.d.ts +20 -0
  4. package/dist/annotations/AnnotationRegistry.d.ts.map +1 -0
  5. package/dist/annotations/AnnotationRegistry.js +100 -0
  6. package/dist/annotations/AnnotationRegistry.js.map +1 -0
  7. package/dist/annotations/singleton.d.ts +7 -0
  8. package/dist/annotations/singleton.d.ts.map +1 -0
  9. package/dist/annotations/singleton.js +7 -0
  10. package/dist/annotations/singleton.js.map +1 -0
  11. package/dist/annotations/types.d.ts +22 -0
  12. package/dist/annotations/types.d.ts.map +1 -0
  13. package/dist/annotations/types.js +2 -0
  14. package/dist/annotations/types.js.map +1 -0
  15. package/dist/annotations/useViewAnnotation.d.ts +15 -0
  16. package/dist/annotations/useViewAnnotation.d.ts.map +1 -0
  17. package/dist/annotations/useViewAnnotation.js +42 -0
  18. package/dist/annotations/useViewAnnotation.js.map +1 -0
  19. package/dist/approvals/ApprovalCard.d.ts +54 -0
  20. package/dist/approvals/ApprovalCard.d.ts.map +1 -0
  21. package/dist/approvals/ApprovalCard.js +65 -0
  22. package/dist/approvals/ApprovalCard.js.map +1 -0
  23. package/dist/approvals/decision.d.ts +17 -0
  24. package/dist/approvals/decision.d.ts.map +1 -0
  25. package/dist/approvals/decision.js +25 -0
  26. package/dist/approvals/decision.js.map +1 -0
  27. package/dist/entity/AgentEntity.d.ts +58 -0
  28. package/dist/entity/AgentEntity.d.ts.map +1 -0
  29. package/dist/entity/AgentEntity.js +97 -0
  30. package/dist/entity/AgentEntity.js.map +1 -0
  31. package/dist/entity/AgentEntityComponent.d.ts +73 -0
  32. package/dist/entity/AgentEntityComponent.d.ts.map +1 -0
  33. package/dist/entity/AgentEntityComponent.js +134 -0
  34. package/dist/entity/AgentEntityComponent.js.map +1 -0
  35. package/dist/entity/asAgentEntity.d.ts +45 -0
  36. package/dist/entity/asAgentEntity.d.ts.map +1 -0
  37. package/dist/entity/asAgentEntity.js +51 -0
  38. package/dist/entity/asAgentEntity.js.map +1 -0
  39. package/dist/entity/defineAgentEntity.d.ts +54 -0
  40. package/dist/entity/defineAgentEntity.d.ts.map +1 -0
  41. package/dist/entity/defineAgentEntity.js +133 -0
  42. package/dist/entity/defineAgentEntity.js.map +1 -0
  43. package/dist/entity/index.d.ts +10 -0
  44. package/dist/entity/index.d.ts.map +1 -0
  45. package/dist/entity/index.js +6 -0
  46. package/dist/entity/index.js.map +1 -0
  47. package/dist/entity/useViewAnnotation.d.ts +64 -0
  48. package/dist/entity/useViewAnnotation.d.ts.map +1 -0
  49. package/dist/entity/useViewAnnotation.js +126 -0
  50. package/dist/entity/useViewAnnotation.js.map +1 -0
  51. package/dist/hooks/useFeedback.d.ts +7 -0
  52. package/dist/hooks/useFeedback.d.ts.map +1 -0
  53. package/dist/hooks/useFeedback.js +38 -0
  54. package/dist/hooks/useFeedback.js.map +1 -0
  55. package/dist/index.d.ts +12 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +11 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/provider/AgentProvider.d.ts +25 -0
  60. package/dist/provider/AgentProvider.d.ts.map +1 -0
  61. package/dist/provider/AgentProvider.js +800 -0
  62. package/dist/provider/AgentProvider.js.map +1 -0
  63. package/dist/provider/socketio.d.ts +8 -0
  64. package/dist/provider/socketio.d.ts.map +1 -0
  65. package/dist/provider/socketio.js +19 -0
  66. package/dist/provider/socketio.js.map +1 -0
  67. package/dist/provider/stored-messages.d.ts +16 -0
  68. package/dist/provider/stored-messages.d.ts.map +1 -0
  69. package/dist/provider/stored-messages.js +57 -0
  70. package/dist/provider/stored-messages.js.map +1 -0
  71. package/dist/provider/types.d.ts +158 -0
  72. package/dist/provider/types.d.ts.map +1 -0
  73. package/dist/provider/types.js +2 -0
  74. package/dist/provider/types.js.map +1 -0
  75. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Closure Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @ouispec/agent-react
2
+
3
+ The agent in a React app: the provider that runs turns against the product's API and realtime server, the hooks a chat UI is built from, and the card where a person approves an irreversible action.
4
+
5
+ ```sh
6
+ npm install @ouispec/agent-react
7
+ ```
8
+
9
+ - `AgentProvider` and `useAgent`: the conversation, its messages and tool calls, sending a turn, and the turn's stream. The socket is a seam (`realtime.createSocket`), so a product supplies its own connection and credentials.
10
+ - `ApprovalCard`: shows what an irreversible call will do and takes the person's decision. It can't be bound to the agent: only a person's click approves.
11
+ - `useFeedback`, `storedToAgentMessages`, and the view annotations.
12
+
13
+ React 18 or 19 is a peer dependency. It releases with the rest of the agent SDK, under one version: see [VERSIONING.md](https://github.com/wesreid/oui/blob/main/VERSIONING.md).
@@ -0,0 +1,20 @@
1
+ import type { ViewAnnotationState } from '@ouispec/agent-core';
2
+ import type { AnnotationEntry, AnnotationListener } from './types.js';
3
+ /**
4
+ * Registry of view annotations — tracks which entities are visible on screen.
5
+ * Replaces PA's PATargetRegistry with entity-bound annotations.
6
+ */
7
+ export declare class AnnotationRegistry {
8
+ private entries;
9
+ private listeners;
10
+ private observer;
11
+ constructor();
12
+ register(entry: AnnotationEntry): () => void;
13
+ updateElement(id: string, element: HTMLElement | null): void;
14
+ getVisibleAnnotations(): ViewAnnotationState[];
15
+ resolveEntity(type: string, id: string): AnnotationEntry | undefined;
16
+ resolveByContext(description: string): AnnotationEntry[];
17
+ subscribe(listener: AnnotationListener): () => void;
18
+ private notify;
19
+ }
20
+ //# sourceMappingURL=AnnotationRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationRegistry.d.ts","sourceRoot":"","sources":["../../src/annotations/AnnotationRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,QAAQ,CAAqC;;IAwBrD,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,IAAI;IAoB5C,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI;IAgB5D,qBAAqB,IAAI,mBAAmB,EAAE;IAqB9C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IASpE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,EAAE;IAOxD,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAKnD,OAAO,CAAC,MAAM;CAKf"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Registry of view annotations — tracks which entities are visible on screen.
3
+ * Replaces PA's PATargetRegistry with entity-bound annotations.
4
+ */
5
+ export class AnnotationRegistry {
6
+ entries = new Map();
7
+ listeners = new Set();
8
+ observer = null;
9
+ constructor() {
10
+ if (typeof IntersectionObserver !== 'undefined') {
11
+ this.observer = new IntersectionObserver((entries) => {
12
+ let changed = false;
13
+ for (const ioEntry of entries) {
14
+ const id = ioEntry.target.dataset.agentAnnotationId;
15
+ if (!id)
16
+ continue;
17
+ const annotation = this.entries.get(id);
18
+ if (annotation && annotation.visible !== ioEntry.isIntersecting) {
19
+ annotation.visible = ioEntry.isIntersecting;
20
+ annotation.rect = ioEntry.isIntersecting ? ioEntry.boundingClientRect : undefined;
21
+ changed = true;
22
+ }
23
+ }
24
+ if (changed)
25
+ this.notify();
26
+ }, { threshold: 0.1 });
27
+ }
28
+ }
29
+ register(entry) {
30
+ const id = entry.id;
31
+ this.entries.set(id, entry);
32
+ if (entry.element && this.observer) {
33
+ entry.element.dataset.agentAnnotationId = id;
34
+ this.observer.observe(entry.element);
35
+ }
36
+ this.notify();
37
+ return () => {
38
+ if (entry.element && this.observer) {
39
+ this.observer.unobserve(entry.element);
40
+ }
41
+ this.entries.delete(id);
42
+ this.notify();
43
+ };
44
+ }
45
+ updateElement(id, element) {
46
+ const entry = this.entries.get(id);
47
+ if (!entry)
48
+ return;
49
+ if (entry.element && this.observer) {
50
+ this.observer.unobserve(entry.element);
51
+ }
52
+ entry.element = element;
53
+ if (element && this.observer) {
54
+ element.dataset.agentAnnotationId = id;
55
+ this.observer.observe(element);
56
+ }
57
+ }
58
+ getVisibleAnnotations() {
59
+ const annotations = [];
60
+ for (const [id, entry] of this.entries) {
61
+ annotations.push({
62
+ elementId: id,
63
+ entity: entry.options.entity,
64
+ intents: entry.options.intents ?? [],
65
+ displayContext: entry.options.displayContext,
66
+ rect: entry.rect ? {
67
+ x: entry.rect.x,
68
+ y: entry.rect.y,
69
+ width: entry.rect.width,
70
+ height: entry.rect.height,
71
+ } : undefined,
72
+ visible: entry.visible,
73
+ ...(entry.options.metadata ? { metadata: entry.options.metadata } : {}),
74
+ });
75
+ }
76
+ return annotations;
77
+ }
78
+ resolveEntity(type, id) {
79
+ for (const entry of this.entries.values()) {
80
+ if (entry.options.entity.type === type && entry.options.entity.id === id) {
81
+ return entry;
82
+ }
83
+ }
84
+ return undefined;
85
+ }
86
+ resolveByContext(description) {
87
+ const lower = description.toLowerCase();
88
+ return [...this.entries.values()].filter(e => e.visible && e.options.displayContext.label.toLowerCase().includes(lower));
89
+ }
90
+ subscribe(listener) {
91
+ this.listeners.add(listener);
92
+ return () => this.listeners.delete(listener);
93
+ }
94
+ notify() {
95
+ for (const listener of this.listeners) {
96
+ listener();
97
+ }
98
+ }
99
+ }
100
+ //# sourceMappingURL=AnnotationRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationRegistry.js","sourceRoot":"","sources":["../../src/annotations/AnnotationRegistry.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC7C,SAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC1C,QAAQ,GAAgC,IAAI,CAAC;IAErD;QACE,IAAI,OAAO,oBAAoB,KAAK,WAAW,EAAE,CAAC;YAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CACtC,CAAC,OAAO,EAAE,EAAE;gBACV,IAAI,OAAO,GAAG,KAAK,CAAC;gBACpB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;oBAC9B,MAAM,EAAE,GAAI,OAAO,CAAC,MAAsB,CAAC,OAAO,CAAC,iBAAiB,CAAC;oBACrE,IAAI,CAAC,EAAE;wBAAE,SAAS;oBAClB,MAAM,UAAU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* Singleton annotation registry instance for app-wide use.
4
+ * Tracks which annotated entities are currently visible on screen.
5
+ */
6
+ export declare const annotationRegistry: AnnotationRegistry;
7
+ //# sourceMappingURL=singleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/annotations/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AnnotationRegistry } from './AnnotationRegistry.js';
2
+ /**
3
+ * Singleton annotation registry instance for app-wide use.
4
+ * Tracks which annotated entities are currently visible on screen.
5
+ */
6
+ export const annotationRegistry = new AnnotationRegistry();
7
+ //# sourceMappingURL=singleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/annotations/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ export interface ViewAnnotationOptions {
2
+ entity: {
3
+ type: string;
4
+ id: string;
5
+ };
6
+ intents?: string[];
7
+ displayContext: {
8
+ label: string;
9
+ image?: string;
10
+ badge?: string;
11
+ };
12
+ metadata?: Record<string, unknown>;
13
+ }
14
+ export interface AnnotationEntry {
15
+ id: string;
16
+ element: HTMLElement | null;
17
+ options: ViewAnnotationOptions;
18
+ visible: boolean;
19
+ rect?: DOMRect;
20
+ }
21
+ export type AnnotationListener = () => void;
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/annotations/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/annotations/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { ViewAnnotationOptions } from './types.js';
2
+ /**
3
+ * Hook to annotate a UI element with an entity binding.
4
+ * Replaces PA's usePATarget — now entity-aware with contextual resolution.
5
+ *
6
+ * Usage:
7
+ * const ref = useViewAnnotation({
8
+ * entity: { type: 'Character', id: character.id },
9
+ * intents: ['edit-character', 'generate-clip'],
10
+ * displayContext: { label: character.name, image: character.thumbnailUrl },
11
+ * });
12
+ * return <div ref={ref}>...</div>;
13
+ */
14
+ export declare function useViewAnnotation(options: ViewAnnotationOptions): (element: HTMLElement | null) => void;
15
+ //# sourceMappingURL=useViewAnnotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewAnnotation.d.ts","sourceRoot":"","sources":["../../src/annotations/useViewAnnotation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CA+BvG"}
@@ -0,0 +1,42 @@
1
+ import { useRef, useCallback, useEffect } from 'react';
2
+ import { annotationRegistry } from './singleton.js';
3
+ /**
4
+ * Hook to annotate a UI element with an entity binding.
5
+ * Replaces PA's usePATarget — now entity-aware with contextual resolution.
6
+ *
7
+ * Usage:
8
+ * const ref = useViewAnnotation({
9
+ * entity: { type: 'Character', id: character.id },
10
+ * intents: ['edit-character', 'generate-clip'],
11
+ * displayContext: { label: character.name, image: character.thumbnailUrl },
12
+ * });
13
+ * return <div ref={ref}>...</div>;
14
+ */
15
+ export function useViewAnnotation(options) {
16
+ const idRef = useRef(`annotation-${options.entity.type}-${options.entity.id}`);
17
+ const unregisterRef = useRef(null);
18
+ const optionsRef = useRef(options);
19
+ optionsRef.current = options;
20
+ useEffect(() => {
21
+ return () => {
22
+ unregisterRef.current?.();
23
+ };
24
+ }, []);
25
+ const refCallback = useCallback((element) => {
26
+ const id = idRef.current;
27
+ if (unregisterRef.current) {
28
+ unregisterRef.current();
29
+ unregisterRef.current = null;
30
+ }
31
+ if (element) {
32
+ unregisterRef.current = annotationRegistry.register({
33
+ id,
34
+ element,
35
+ options: optionsRef.current,
36
+ visible: false,
37
+ });
38
+ }
39
+ }, []);
40
+ return refCallback;
41
+ }
42
+ //# sourceMappingURL=useViewAnnotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewAnnotation.js","sourceRoot":"","sources":["../../src/annotations/useViewAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA8B;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/E,MAAM,aAAa,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,OAA2B,EAAE,EAAE;QAC9D,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;QAEzB,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;YAC1B,aAAa,CAAC,OAAO,EAAE,CAAC;YACxB,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,aAAa,CAAC,OAAO,GAAG,kBAAkB,CAAC,QAAQ,CAAC;gBAClD,EAAE;gBACF,OAAO;gBACP,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ApprovalCard — where the user approves, or declines, the one irreversible
3
+ * call a turn stopped at (ADR-0228 §2.2.3).
4
+ *
5
+ * It shows what the call does in the action's own declared words (its title,
6
+ * what it does, its arguments by their labels), never the assistant's. A
7
+ * click on Approve or Decline is the only decision there is: it goes to the
8
+ * approval store on the user's own socket, an approval's grant goes to this
9
+ * tab's OUI runtime (`grantApproval` in the client config), and the turn
10
+ * continues with the token outside the message text. A "yes" typed in chat is
11
+ * only a message.
12
+ *
13
+ * The card takes no `agent` prop, and the package declares it person-only
14
+ * (`oui.personOnly`), so the generator refuses to bind it: the assistant can
15
+ * never operate its own approval. It renders its own buttons; a host draws it
16
+ * with its design system's parts through `components`.
17
+ */
18
+ import React, { type ComponentType, type ReactNode } from 'react';
19
+ /** The frame: a design system's card, with a title, a line under it, a body and actions. */
20
+ export interface ApprovalCardFrameProps {
21
+ title: ReactNode;
22
+ subtitle?: ReactNode;
23
+ /** Always `warning`: the call cannot be undone. */
24
+ tone?: 'default' | 'warning' | 'error';
25
+ actions?: ReactNode;
26
+ children?: ReactNode;
27
+ }
28
+ /** A button: Approve is `primary`, Decline and Dismiss `secondary`. */
29
+ export interface ApprovalCardButtonProps {
30
+ variant?: 'primary' | 'secondary';
31
+ onClick?: () => unknown;
32
+ disabled?: boolean;
33
+ children?: ReactNode;
34
+ }
35
+ export interface ApprovalCardParts {
36
+ Card: ComponentType<ApprovalCardFrameProps>;
37
+ Button: ComponentType<ApprovalCardButtonProps>;
38
+ }
39
+ export interface ApprovalCardLabels {
40
+ approve: string;
41
+ decline: string;
42
+ dismiss: string;
43
+ waiting: string;
44
+ expired: string;
45
+ }
46
+ export interface ApprovalCardProps {
47
+ /** The host's own card and button. Default: plain, unstyled HTML. */
48
+ components?: Partial<ApprovalCardParts>;
49
+ /** The card's own words, for another language. */
50
+ labels?: Partial<ApprovalCardLabels>;
51
+ }
52
+ /** Renders nothing until a turn stops for the user's approval. */
53
+ export declare function ApprovalCard({ components, labels }: ApprovalCardProps): React.JSX.Element | null;
54
+ //# sourceMappingURL=ApprovalCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalCard.d.ts","sourceRoot":"","sources":["../../src/approvals/ApprovalCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,EAAmC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGnG,4FAA4F;AAC5F,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,mDAAmD;IACnD,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAC5C,MAAM,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxC,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtC;AA6BD,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,4BAgDrE"}
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * ApprovalCard — where the user approves, or declines, the one irreversible
4
+ * call a turn stopped at (ADR-0228 §2.2.3).
5
+ *
6
+ * It shows what the call does in the action's own declared words (its title,
7
+ * what it does, its arguments by their labels), never the assistant's. A
8
+ * click on Approve or Decline is the only decision there is: it goes to the
9
+ * approval store on the user's own socket, an approval's grant goes to this
10
+ * tab's OUI runtime (`grantApproval` in the client config), and the turn
11
+ * continues with the token outside the message text. A "yes" typed in chat is
12
+ * only a message.
13
+ *
14
+ * The card takes no `agent` prop, and the package declares it person-only
15
+ * (`oui.personOnly`), so the generator refuses to bind it: the assistant can
16
+ * never operate its own approval. It renders its own buttons; a host draws it
17
+ * with its design system's parts through `components`.
18
+ */
19
+ import React, { useContext, useEffect, useState } from 'react';
20
+ import { ApprovalDecisionContext } from './decision.js';
21
+ const DEFAULT_LABELS = {
22
+ approve: 'Approve',
23
+ decline: 'Decline',
24
+ dismiss: 'Dismiss',
25
+ waiting: 'This runs only if you approve it here.',
26
+ expired: 'This approval has expired.',
27
+ };
28
+ function PlainCard({ title, subtitle, actions, children }) {
29
+ return (_jsxs("section", { "aria-label": typeof title === 'string' ? title : undefined, children: [_jsx("h3", { children: title }), subtitle ? _jsx("p", { children: subtitle }) : null, children, _jsx("div", { children: actions })] }));
30
+ }
31
+ function PlainButton({ onClick, disabled, children }) {
32
+ return (_jsx("button", { type: "button", disabled: disabled, onClick: () => void onClick?.(), children: children }));
33
+ }
34
+ /** Renders nothing until a turn stops for the user's approval. */
35
+ export function ApprovalCard({ components, labels }) {
36
+ const decision = useContext(ApprovalDecisionContext);
37
+ if (!decision)
38
+ throw new Error('ApprovalCard must be used within an AgentProvider');
39
+ const { pending, deciding, error, decide, dismiss } = decision;
40
+ const expired = useExpired(pending?.expiresAt);
41
+ if (!pending)
42
+ return null;
43
+ const Card = components?.Card ?? PlainCard;
44
+ const Button = components?.Button ?? PlainButton;
45
+ const text = { ...DEFAULT_LABELS, ...labels };
46
+ const closed = expired || error !== null;
47
+ const { preview } = pending;
48
+ return (_jsxs(Card, { title: preview.title, subtitle: preview.consequence, tone: "warning", actions: _jsxs(_Fragment, { children: [closed ? (_jsx(Button, { variant: "secondary", onClick: dismiss, disabled: deciding, children: error !== null ? text.dismiss : text.decline })) : (_jsx(Button, { variant: "secondary", onClick: () => decide('decline'), disabled: deciding, children: text.decline })), _jsx(Button, { variant: "primary", onClick: () => decide('approve'), disabled: deciding || closed, children: text.approve })] }), children: [preview.arguments.length > 0 ? (_jsx("dl", { children: preview.arguments.map(arg => (_jsxs(React.Fragment, { children: [_jsx("dt", { children: arg.label }), _jsx("dd", { children: arg.value })] }, arg.name))) })) : null, error !== null ? _jsx("p", { role: "alert", children: error }) : _jsx("p", { children: expired ? text.expired : text.waiting })] }));
49
+ }
50
+ /** Whether `expiresAt` has passed, turning true when it does. */
51
+ function useExpired(expiresAt) {
52
+ const [now, setNow] = useState(() => Date.now());
53
+ useEffect(() => {
54
+ if (expiresAt === undefined)
55
+ return;
56
+ setNow(Date.now());
57
+ const left = expiresAt - Date.now();
58
+ if (left <= 0)
59
+ return;
60
+ const timer = setTimeout(() => setNow(Date.now()), left);
61
+ return () => clearTimeout(timer);
62
+ }, [expiresAt]);
63
+ return expiresAt !== undefined && now >= expiresAt;
64
+ }
65
+ //# sourceMappingURL=ApprovalCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalCard.js","sourceRoot":"","sources":["../../src/approvals/ApprovalCard.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAwCxD,MAAM,cAAc,GAAuB;IACzC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,wCAAwC;IACjD,OAAO,EAAE,4BAA4B;CACtC,CAAC;AAEF,SAAS,SAAS,CAAC,EAA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C,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,GAAK,IACzF,CACR,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,SAAS,UAAU,CAAC,SAA6B;IAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO;QACpC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACnB,MAAM,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACpC,IAAI,IAAI,IAAI,CAAC;YAAE,OAAO;QACtB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACzD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAChB,OAAO,SAAS,KAAK,SAAS,IAAI,GAAG,IAAI,SAAS,CAAC;AACrD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { ApprovalDecision, ApprovalRefusal } from '@ouispec/agent-core';
2
+ import type { AgentApprovalRequest } from '../provider/types.js';
3
+ export interface ApprovalDecisionState {
4
+ pending: AgentApprovalRequest | null;
5
+ /** True while the approval store answers the click. */
6
+ deciding: boolean;
7
+ /** Why the last decision was refused, for the user. */
8
+ error: string | null;
9
+ /** The user's click: decides on their own socket, then continues the turn. */
10
+ decide: (decision: ApprovalDecision) => Promise<void>;
11
+ /** Puts the card away after a refusal; nothing is decided. */
12
+ dismiss: () => void;
13
+ }
14
+ export declare const ApprovalDecisionContext: import("react").Context<ApprovalDecisionState | null>;
15
+ /** What the user is told when the store refuses their decision. */
16
+ export declare function approvalRefusalText(refusal: ApprovalRefusal): string;
17
+ //# sourceMappingURL=decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/approvals/decision.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrC,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8EAA8E;IAC9E,MAAM,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,8DAA8D;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,uBAAuB,uDAAoD,CAAC;AAEzF,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAcpE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The approval card's own channel to the provider: the pending approval and
3
+ * the user's decision on it. Deliberately not part of `useAgent()` and not
4
+ * exported from the package, so the only thing in a page that can approve is
5
+ * `ApprovalCard`, which no build may bind for the assistant (ADR-0228 §2.2.3).
6
+ */
7
+ import { createContext } from 'react';
8
+ export const ApprovalDecisionContext = createContext(null);
9
+ /** What the user is told when the store refuses their decision. */
10
+ export function approvalRefusalText(refusal) {
11
+ switch (refusal.reason) {
12
+ case 'expired':
13
+ return 'This approval has expired. Ask the assistant again if you still want it done.';
14
+ case 'decided':
15
+ case 'used':
16
+ return 'This has already been decided.';
17
+ case 'unknown':
18
+ return 'This approval is no longer waiting. Ask the assistant again if you still want it done.';
19
+ case 'forbidden':
20
+ return 'This approval belongs to someone else.';
21
+ default:
22
+ return `Your decision could not be recorded: ${refusal.error}.`;
23
+ }
24
+ }
25
+ //# sourceMappingURL=decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.js","sourceRoot":"","sources":["../../src/approvals/decision.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAgBtC,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AAEzF,mEAAmE;AACnE,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACvB,KAAK,SAAS;YACZ,OAAO,+EAA+E,CAAC;QACzF,KAAK,SAAS,CAAC;QACf,KAAK,MAAM;YACT,OAAO,gCAAgC,CAAC;QAC1C,KAAK,SAAS;YACZ,OAAO,wFAAwF,CAAC;QAClG,KAAK,WAAW;YACd,OAAO,wCAAwC,CAAC;QAClD;YACE,OAAO,wCAAwC,OAAO,CAAC,KAAK,GAAG,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import type { EntityCapabilities, EntityDisplayContext, AgentAction, AgentCommand, AgentCommandResponse, UserObservation, EntityExecuteOptions, IntentResult } from '@ouispec/agent-core';
3
+ /**
4
+ * Props for the <AgentEntity> wrapper component.
5
+ */
6
+ export interface AgentEntityProps {
7
+ type: string;
8
+ id: string;
9
+ intents?: string[];
10
+ displayContext: EntityDisplayContext;
11
+ capabilities?: EntityCapabilities;
12
+ onTargeted?: (action: AgentAction) => void;
13
+ onReleased?: () => void;
14
+ onExecuting?: (intentId: string, params: Record<string, unknown>) => void;
15
+ onExecutionComplete?: (intentId: string, result: IntentResult) => void;
16
+ onCommandReceived?: (command: AgentCommand) => AgentCommandResponse | Promise<AgentCommandResponse> | void;
17
+ onObserve?: (observation: UserObservation) => void;
18
+ children: React.ReactNode | ((context: AgentEntityChildContext) => React.ReactNode);
19
+ as?: keyof React.JSX.IntrinsicElements;
20
+ className?: string;
21
+ style?: React.CSSProperties;
22
+ }
23
+ /**
24
+ * Context passed to render-prop children of <AgentEntity>.
25
+ */
26
+ export interface AgentEntityChildContext {
27
+ isTargeted: boolean;
28
+ isExecuting: boolean;
29
+ currentAction: AgentAction | null;
30
+ execute: (intentId: string, params?: Record<string, unknown>, options?: EntityExecuteOptions) => Promise<IntentResult>;
31
+ emit: (signal: string, data?: unknown) => void;
32
+ }
33
+ /**
34
+ * <AgentEntity> — wrapper component that grants agent capabilities to its children.
35
+ *
36
+ * Simplest integration pattern. Wrap any component to make it agent-addressable.
37
+ *
38
+ * Example:
39
+ * ```tsx
40
+ * <AgentEntity type="Character" id={char.id} displayContext={{ label: char.name }}>
41
+ * <CharacterCard character={char} />
42
+ * </AgentEntity>
43
+ *
44
+ * // Or with render prop:
45
+ * <AgentEntity type="Character" id={char.id} displayContext={{ label: char.name }}>
46
+ * {({ isTargeted, execute }) => (
47
+ * <div className={isTargeted ? 'highlighted' : ''}>
48
+ * <CharacterCard character={char} />
49
+ * <button onClick={() => execute('generate-clip', { character: char.id })}>
50
+ * Generate
51
+ * </button>
52
+ * </div>
53
+ * )}
54
+ * </AgentEntity>
55
+ * ```
56
+ */
57
+ export declare function AgentEntity(props: AgentEntityProps): React.ReactElement;
58
+ //# sourceMappingURL=AgentEntity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentEntity.d.ts","sourceRoot":"","sources":["../../src/entity/AgentEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,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