@personaai/react 0.10.0 → 0.11.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.
package/dist/index.d.ts CHANGED
@@ -620,6 +620,293 @@ interface UseWorkflowRunsOptions {
620
620
  page?: number;
621
621
  limit?: number;
622
622
  }
623
+ /** Shared list envelope every Developer Platform discovery endpoint uses (Agents/Skills/Knowledge/MCP/Threads/Files). */
624
+ interface PersonaPagination {
625
+ total: number;
626
+ page: number;
627
+ limit: number;
628
+ pages: number;
629
+ }
630
+ /** `{ deleted, failed }` from a `POST .../bulk-delete` — a best-effort batch, not all-or-nothing; check `failed` for per-id reasons. */
631
+ interface PersonaBulkDeleteResult {
632
+ deleted: string[];
633
+ failed: Array<{
634
+ id: string;
635
+ reason: string;
636
+ }>;
637
+ }
638
+ /** A file bundled with a Skill (e.g. a reference doc or script an Agent can read). */
639
+ interface PersonaSkillFile {
640
+ path: string;
641
+ content: string;
642
+ mimeType?: string;
643
+ createdAt?: string;
644
+ updatedAt?: string;
645
+ }
646
+ interface PersonaSkill {
647
+ _id: string;
648
+ domain: string;
649
+ ownerType: "PersonaUser" | "Project" | "ExternalUser";
650
+ ownerId?: string;
651
+ externalOwnerId?: string;
652
+ name: string;
653
+ description: string;
654
+ instructions: string;
655
+ files: PersonaSkillFile[];
656
+ /** Visible to every credential in the platform when `true`, not just this Domain. */
657
+ isPublic: boolean;
658
+ createdAt: string;
659
+ updatedAt: string;
660
+ /** Present only on a single `getSkill()` read — whether the calling identity owns this Skill. */
661
+ isOwner?: boolean;
662
+ }
663
+ interface CreatePersonaSkillInput {
664
+ name: string;
665
+ description: string;
666
+ /** The actual prompt text given to an Agent that has this Skill attached. */
667
+ instructions: string;
668
+ /** @default false */
669
+ isPublic?: boolean;
670
+ files?: Array<{
671
+ path: string;
672
+ content: string;
673
+ mimeType?: string;
674
+ }>;
675
+ }
676
+ /** All fields optional — only what you pass is changed. */
677
+ interface UpdatePersonaSkillInput {
678
+ name?: string;
679
+ description?: string;
680
+ instructions?: string;
681
+ isPublic?: boolean;
682
+ /** Replaces the entire `files` array — not a merge/append. */
683
+ files?: Array<{
684
+ path: string;
685
+ content: string;
686
+ mimeType?: string;
687
+ }>;
688
+ }
689
+ /** Agents referencing a Skill — check before deleting it to avoid a blocked-delete error. */
690
+ interface PersonaSkillUsage {
691
+ /** The real total — `agents` below is a preview capped at 20. */
692
+ agentCount: number;
693
+ agents: Array<{
694
+ _id: string;
695
+ name: string;
696
+ }>;
697
+ }
698
+ interface UseSkillsOptions {
699
+ /** @default true */
700
+ autoFetch?: boolean;
701
+ page?: number;
702
+ limit?: number;
703
+ /** Free-text match against name/description. */
704
+ search?: string;
705
+ /** Restricts to the asserted external user's own Skills. Requires a `ProjectRuntimeContext` (i.e. `PersonaProvider` talking through an adapter with `resolveUserFrom`/`resolveUser`) — a no-op otherwise. */
706
+ scope?: "mine";
707
+ }
708
+ interface PersonaAgentSocialLinks {
709
+ website?: string;
710
+ twitter?: string;
711
+ github?: string;
712
+ linkedin?: string;
713
+ }
714
+ /** `unlisted` is reachable by direct link/id but excluded from public discovery listings. */
715
+ type PersonaAgentVisibility = "private" | "unlisted" | "public";
716
+ type PersonaAgentCategory = "productivity" | "coding" | "creative" | "research" | "roleplay" | "other";
717
+ /**
718
+ * Mirrors the real wire shape (`_id`, raw domain/ownerType fields) —
719
+ * `getAgent()` returns `skills`/`mcps`/`knowledgeBases` populated as
720
+ * objects, while `createAgent()`/`updateAgent()`/`agents` (from the list)
721
+ * return them as bare id strings; typed loosely (`unknown[]`) to reflect
722
+ * that real difference rather than picking one shape and being wrong for
723
+ * the other calls.
724
+ */
725
+ interface PersonaAgent {
726
+ _id: string;
727
+ domain: string;
728
+ ownerType: "PersonaUser" | "Project" | "ExternalUser";
729
+ ownerId?: string;
730
+ externalOwnerId?: string;
731
+ name: string;
732
+ /** URL-safe, unique within the Domain; used in some public-facing routes. */
733
+ slug: string;
734
+ description?: string;
735
+ avatar?: string;
736
+ tags?: string[];
737
+ /** Short one-liner shown in list/card views. */
738
+ tagline?: string;
739
+ /** Longer free-text bio shown on the Agent's own profile view. */
740
+ bio?: string;
741
+ personalityTraits?: string[];
742
+ socialLinks?: PersonaAgentSocialLinks;
743
+ /** Stripped from the response when the calling identity doesn't own this Agent. */
744
+ systemPrompt?: string;
745
+ /** Stripped from the response when the calling identity doesn't own this Agent. */
746
+ providerId?: string;
747
+ /** Overrides the referenced Provider's `defaultModel` when set. */
748
+ modelName?: string;
749
+ webSearchEnabled: boolean;
750
+ /** Real shell execution in an isolated CodeSandbox VM — requires a `CSB_API_KEY` Project Secret to already exist. */
751
+ sandboxEnabled: boolean;
752
+ visibility: PersonaAgentVisibility;
753
+ category: PersonaAgentCategory;
754
+ skills?: unknown[];
755
+ mcps?: unknown[];
756
+ knowledgeBases?: unknown[];
757
+ storeMounts?: unknown[];
758
+ /** Maps a tool name to whether calling it pauses the run for human approval. */
759
+ interruptOn?: Record<string, boolean>;
760
+ isActive: boolean;
761
+ /** Whether this is the Project's designated default/primary Agent. */
762
+ isMainAgent: boolean;
763
+ createdAt: string;
764
+ updatedAt: string;
765
+ }
766
+ interface CreatePersonaAgentInput {
767
+ name: string;
768
+ /** The instructions that define this Agent's behavior/persona. */
769
+ systemPrompt: string;
770
+ /** Must reference a Provider the host Project already created. */
771
+ providerId: string;
772
+ description?: string;
773
+ avatar?: string;
774
+ tags?: string[];
775
+ tagline?: string;
776
+ bio?: string;
777
+ personalityTraits?: string[];
778
+ socialLinks?: PersonaAgentSocialLinks;
779
+ modelName?: string;
780
+ /** @default false */
781
+ webSearchEnabled?: boolean;
782
+ /** @default false */
783
+ sandboxEnabled?: boolean;
784
+ /** @default 'private' */
785
+ visibility?: PersonaAgentVisibility;
786
+ /** @default 'other' */
787
+ category?: PersonaAgentCategory;
788
+ /** Skill ids to attach at creation time. */
789
+ skills?: string[];
790
+ /** MCP server ids to attach at creation time. */
791
+ mcps?: string[];
792
+ /** Knowledge base ids to attach at creation time. */
793
+ knowledgeBases?: string[];
794
+ /** Store ids to mount at creation time. */
795
+ storeMounts?: string[];
796
+ interruptOn?: Record<string, boolean>;
797
+ /** @default true */
798
+ isActive?: boolean;
799
+ }
800
+ /** All fields optional — only what you pass is changed; array/map fields replace the whole value, not a merge/append. */
801
+ interface UpdatePersonaAgentInput {
802
+ name?: string;
803
+ description?: string;
804
+ avatar?: string;
805
+ tags?: string[];
806
+ tagline?: string;
807
+ bio?: string;
808
+ personalityTraits?: string[];
809
+ socialLinks?: PersonaAgentSocialLinks;
810
+ systemPrompt?: string;
811
+ providerId?: string;
812
+ modelName?: string;
813
+ webSearchEnabled?: boolean;
814
+ sandboxEnabled?: boolean;
815
+ skills?: string[];
816
+ mcps?: string[];
817
+ knowledgeBases?: string[];
818
+ storeMounts?: string[];
819
+ interruptOn?: Record<string, boolean>;
820
+ visibility?: PersonaAgentVisibility;
821
+ category?: PersonaAgentCategory;
822
+ isActive?: boolean;
823
+ }
824
+ interface UseAgentsOptions {
825
+ /** @default true */
826
+ autoFetch?: boolean;
827
+ page?: number;
828
+ limit?: number;
829
+ /** Free-text match against name/description/tagline. */
830
+ search?: string;
831
+ category?: PersonaAgentCategory;
832
+ /** Restricts to the asserted external user's own Agents. Requires a `ProjectRuntimeContext` — a no-op otherwise. */
833
+ scope?: "mine";
834
+ }
835
+ interface PersonaRcpSourceToolParamSummary {
836
+ name: string;
837
+ type: string;
838
+ description: string;
839
+ required: boolean;
840
+ }
841
+ /** A display cache only, written by `testRcpSourceConnection` — Agent execution discovers tools live via `rcp-sdk`, never reads this. */
842
+ interface PersonaRcpSourceToolSummary {
843
+ name: string;
844
+ description: string;
845
+ method: string;
846
+ url: string;
847
+ /** Every param this tool exposes (never resolver-filtered) — needed client-side to build `paramContextMap`. */
848
+ params: PersonaRcpSourceToolParamSummary[];
849
+ }
850
+ /** Maps one of this source's tool param names to a key sent in a message's per-turn `context` — see `SendMessageOverride.context`. Shared across every Agent this source is attached to, not per-attachment. */
851
+ interface PersonaRcpParamContextMapEntry {
852
+ param: string;
853
+ contextKey: string;
854
+ }
855
+ /** A hosted RCP (REST Connector Protocol, npm `rcp-sdk`) manifest URL Persona discovers tools from live on every Agent run. */
856
+ interface PersonaRcpSource {
857
+ _id: string;
858
+ domain: string;
859
+ ownerType: "PersonaUser" | "Project" | "ExternalUser";
860
+ ownerId?: string;
861
+ externalOwnerId?: string;
862
+ name: string;
863
+ description: string;
864
+ /** `GET url` must return a conformant `{ rcpVersion, auth, tools[] }` manifest. */
865
+ url: string;
866
+ authType: "none" | "header";
867
+ /** A Project Secret id — present only when `authType` is `'header'`. Never returns the secret's plaintext value. */
868
+ secretRef?: string | null;
869
+ isEnabled: boolean;
870
+ lastTestedAt?: string | null;
871
+ tools: PersonaRcpSourceToolSummary[];
872
+ paramContextMap: PersonaRcpParamContextMapEntry[];
873
+ createdAt: string;
874
+ updatedAt: string;
875
+ }
876
+ interface CreatePersonaRcpSourceInput {
877
+ name: string;
878
+ description?: string;
879
+ url: string;
880
+ /** @default 'none' */
881
+ authType?: "none" | "header";
882
+ /** A Project Secret id. Required when `authType` is `'header'`. */
883
+ secretRef?: string;
884
+ /** @default true */
885
+ isEnabled?: boolean;
886
+ paramContextMap?: PersonaRcpParamContextMapEntry[];
887
+ }
888
+ /** All fields optional — only what you pass is changed. */
889
+ interface UpdatePersonaRcpSourceInput {
890
+ name?: string;
891
+ description?: string;
892
+ url?: string;
893
+ authType?: "none" | "header";
894
+ secretRef?: string | null;
895
+ isEnabled?: boolean;
896
+ paramContextMap?: PersonaRcpParamContextMapEntry[];
897
+ }
898
+ /** From `testConnection()` — discovers the source's manifest live and persists it as the new display cache. */
899
+ interface PersonaRcpSourceTestResult {
900
+ tools: PersonaRcpSourceToolSummary[];
901
+ }
902
+ interface UseRcpSourcesOptions {
903
+ /** @default true */
904
+ autoFetch?: boolean;
905
+ page?: number;
906
+ limit?: number;
907
+ /** Free-text match against name. */
908
+ search?: string;
909
+ }
623
910
 
624
911
  interface PersonaContextValue {
625
912
  baseUrl: string;
@@ -803,19 +1090,31 @@ declare function useFiles(autoFetch?: boolean): {
803
1090
  getDownloadUrl: (fileId: string) => string;
804
1091
  };
805
1092
 
806
- interface PersonaAgentSummary {
807
- _id: string;
808
- name: string;
809
- slug: string;
810
- description?: string;
811
- tagline?: string;
812
- avatar?: string;
813
- }
814
- declare function useAgents(autoFetch?: boolean): {
815
- agents: PersonaAgentSummary[];
1093
+ /**
1094
+ * Read-only discovery (`agents`) is always on. Create/update/delete/
1095
+ * bulk-delete/getAgent require the host's `createPersonaHandler`/
1096
+ * `createRuntime` to opt in with `capabilities: { agentsWrite: true }` —
1097
+ * every write route this hook calls 404s/is unreachable otherwise
1098
+ * (provisioning Agents is Project-level work the host must deliberately
1099
+ * turn on, not something a chat session gets by default).
1100
+ *
1101
+ * Ownership follows the same self-serve model as `useSkills`/`useWorkflows`:
1102
+ * pass `scope: 'mine'` to restrict `agents` to the asserted external user's
1103
+ * own Agents (only meaningful when `PersonaProvider` is wired through an
1104
+ * adapter that resolves a real end-user identity) — omit it to see every
1105
+ * Agent visible to this Project.
1106
+ */
1107
+ declare function useAgents(options?: UseAgentsOptions | boolean): {
1108
+ agents: PersonaAgent[];
1109
+ pagination: PersonaPagination;
816
1110
  isLoading: boolean;
817
1111
  error: Error | null;
818
- refetch: () => Promise<PersonaAgentSummary[]>;
1112
+ refetch: () => Promise<PersonaAgent[]>;
1113
+ getAgent: (agentId: string) => Promise<PersonaAgent>;
1114
+ createAgent: (input: CreatePersonaAgentInput) => Promise<PersonaAgent>;
1115
+ updateAgent: (agentId: string, input: UpdatePersonaAgentInput) => Promise<PersonaAgent>;
1116
+ deleteAgent: (agentId: string) => Promise<void>;
1117
+ bulkDeleteAgents: (ids: string[]) => Promise<PersonaBulkDeleteResult>;
819
1118
  };
820
1119
 
821
1120
  interface PersonaHealthInfo {
@@ -867,6 +1166,8 @@ declare function useMcpConnections(options?: UseMcpConnectionsOptions): {
867
1166
  isLoading: boolean;
868
1167
  error: Error | null;
869
1168
  refetch: () => Promise<PersonaMcpConnection[]>;
1169
+ disconnect: (mcpId: string) => Promise<void>;
1170
+ isDisconnecting: boolean;
870
1171
  };
871
1172
 
872
1173
  interface UseMcpOptions {
@@ -882,6 +1183,71 @@ declare function useMcp(options?: UseMcpOptions): {
882
1183
  callTool: (name: string, args?: Record<string, unknown>, mcpId?: string) => Promise<any>;
883
1184
  };
884
1185
 
1186
+ /**
1187
+ * CRUD for Skills — a reusable instruction + optional file bundle an Agent
1188
+ * can be given. Requires the host's `createPersonaHandler`/`createRuntime`
1189
+ * to opt in with `capabilities: { skills: true }`; every route this hook
1190
+ * calls 404s/is unreachable otherwise (skill authoring is Project-level
1191
+ * content management the host must deliberately turn on, not something a
1192
+ * chat session gets by default).
1193
+ *
1194
+ * Ownership follows the same self-serve model as `useAgents`/`useWorkflows`:
1195
+ * pass `scope: 'mine'` to restrict `skills` to the asserted external user's
1196
+ * own Skills (only meaningful when `PersonaProvider` is wired through an
1197
+ * adapter that resolves a real end-user identity) — omit it to see every
1198
+ * Skill visible to this Project (its own, plus public ones).
1199
+ */
1200
+ declare function useSkills(options?: UseSkillsOptions): {
1201
+ skills: PersonaSkill[];
1202
+ pagination: PersonaPagination;
1203
+ isLoading: boolean;
1204
+ error: Error | null;
1205
+ refetch: () => Promise<PersonaSkill[]>;
1206
+ getSkill: (skillId: string) => Promise<PersonaSkill>;
1207
+ createSkill: (input: CreatePersonaSkillInput) => Promise<PersonaSkill>;
1208
+ updateSkill: (skillId: string, input: UpdatePersonaSkillInput) => Promise<PersonaSkill>;
1209
+ deleteSkill: (skillId: string) => Promise<void>;
1210
+ bulkDeleteSkills: (ids: string[]) => Promise<PersonaBulkDeleteResult>;
1211
+ getSkillUsage: (skillId: string) => Promise<PersonaSkillUsage>;
1212
+ };
1213
+
1214
+ interface PersonaResourceUsage {
1215
+ /** The real total — `agents` below is a preview capped at 20. */
1216
+ agentCount: number;
1217
+ agents: Array<{
1218
+ _id: string;
1219
+ name: string;
1220
+ }>;
1221
+ }
1222
+ /**
1223
+ * CRUD for RCP (REST Connector Protocol, npm `rcp-sdk`) sources — a hosted
1224
+ * manifest URL Persona discovers tools from live on every Agent run.
1225
+ * Requires the host's `createPersonaHandler`/`createRuntime` to opt in with
1226
+ * `capabilities: { rcpSources: true }`; every route this hook calls
1227
+ * 404s/is unreachable otherwise.
1228
+ *
1229
+ * Ownership follows the same self-serve model as `useSkills`/`useAgents`:
1230
+ * an RCP source can be owned by the Project or by the asserted external
1231
+ * user — but unlike Skills there's no `isPublic` concept here, so
1232
+ * `getRcpSource`/list only ever return sources the calling identity
1233
+ * actually owns (no server-side `scope: 'mine'` filter needed or
1234
+ * supported — every visible source already is "mine").
1235
+ */
1236
+ declare function useRcpSources(options?: UseRcpSourcesOptions): {
1237
+ rcpSources: PersonaRcpSource[];
1238
+ pagination: PersonaPagination;
1239
+ isLoading: boolean;
1240
+ error: Error | null;
1241
+ refetch: () => Promise<PersonaRcpSource[]>;
1242
+ getRcpSource: (sourceId: string) => Promise<PersonaRcpSource>;
1243
+ createRcpSource: (input: CreatePersonaRcpSourceInput) => Promise<PersonaRcpSource>;
1244
+ updateRcpSource: (sourceId: string, input: UpdatePersonaRcpSourceInput) => Promise<PersonaRcpSource>;
1245
+ deleteRcpSource: (sourceId: string) => Promise<void>;
1246
+ bulkDeleteRcpSources: (ids: string[]) => Promise<PersonaBulkDeleteResult>;
1247
+ getRcpSourceUsage: (sourceId: string) => Promise<PersonaResourceUsage>;
1248
+ testRcpSourceConnection: (sourceId: string) => Promise<PersonaRcpSourceTestResult>;
1249
+ };
1250
+
885
1251
  interface WorkflowsPagination {
886
1252
  page: number;
887
1253
  limit: number;
@@ -987,4 +1353,4 @@ declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
987
1353
 
988
1354
  declare const VERSION = "0.10.0";
989
1355
 
990
- export { ARCHITECT_AGENT_ID, type CreateWorkflowInput, type OpenSSEOptions, type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaNodeRunState, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeType, type PersonaWorkflowRunSummary, type PersonaWorkflowSummary, type PersonaWorkflowTrigger, type PersonaWorkflowVersionSummary, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type UpdateWorkflowInput, type UseArchitectChatOptions, type UseChatOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useMcp, useMcpConnections, useMemory, usePersonaContext, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows };
1356
+ export { ARCHITECT_AGENT_ID, type CreatePersonaAgentInput, type CreatePersonaRcpSourceInput, type CreatePersonaSkillInput, type CreateWorkflowInput, type OpenSSEOptions, type PersonaAgent, type PersonaAgentCategory, type PersonaAgentSocialLinks, type PersonaAgentVisibility, type PersonaBulkDeleteResult, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaNodeRunState, type PersonaPagination, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaRcpParamContextMapEntry, type PersonaRcpSource, type PersonaRcpSourceTestResult, type PersonaRcpSourceToolParamSummary, type PersonaRcpSourceToolSummary, type PersonaResourceUsage, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaSkill, type PersonaSkillFile, type PersonaSkillUsage, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeType, type PersonaWorkflowRunSummary, type PersonaWorkflowSummary, type PersonaWorkflowTrigger, type PersonaWorkflowVersionSummary, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type UpdatePersonaAgentInput, type UpdatePersonaRcpSourceInput, type UpdatePersonaSkillInput, type UpdateWorkflowInput, type UseAgentsOptions, type UseArchitectChatOptions, type UseChatOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseRcpSourcesOptions, type UseSkillsOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useMcp, useMcpConnections, useMemory, usePersonaContext, useRcpSources, useSkills, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows };