@band-ai/sdk 0.1.4 → 0.1.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.
Files changed (73) hide show
  1. package/README.md +372 -0
  2. package/dist/{ClaudeSDKAdapter-CRq4R-WB.d.cts → ClaudeSDKAdapter-DfjaI5ke.d.cts} +9 -7
  3. package/dist/{ClaudeSDKAdapter-BHOkjN3X.d.ts → ClaudeSDKAdapter-DonPGJ43.d.ts} +9 -7
  4. package/dist/{acp-server-BdRz9_UN.d.cts → acp-server-CUBXIiG6.d.cts} +2 -2
  5. package/dist/{acp-server-B1Da7L6u.d.ts → acp-server-NZAeg-WO.d.ts} +2 -2
  6. package/dist/adapters.cjs +494 -106
  7. package/dist/adapters.d.cts +12 -12
  8. package/dist/adapters.d.ts +12 -12
  9. package/dist/adapters.js +7 -7
  10. package/dist/{backends-SVMT-7l4.d.cts → backends-DYtEhCZG.d.cts} +7 -2
  11. package/dist/{backends-CzDbiQar.d.ts → backends-oYAb7EU-.d.ts} +7 -2
  12. package/dist/{chunk-MSL6CWHY.js → chunk-2BHHR6YW.js} +17 -16
  13. package/dist/{chunk-EDPKUUJL.js → chunk-6RXWL6TC.js} +9 -1
  14. package/dist/{chunk-SFVKOEQH.js → chunk-DNPVCR3S.js} +92 -14
  15. package/dist/{chunk-I5EZG52P.js → chunk-FP237EAG.js} +424 -136
  16. package/dist/{chunk-RHVH2GZR.js → chunk-J3M3PFFY.js} +81 -31
  17. package/dist/{chunk-GVEQ3RAH.js → chunk-MLROFDKR.js} +132 -23
  18. package/dist/{chunk-INA6YZTZ.js → chunk-RDM4TE4B.js} +32 -30
  19. package/dist/chunk-US226AS4.js +130 -0
  20. package/dist/{chunk-W5NDZSYE.js → chunk-XA4N2JPH.js} +1 -1
  21. package/dist/converters.cjs +469 -13
  22. package/dist/converters.d.cts +5 -5
  23. package/dist/converters.d.ts +5 -5
  24. package/dist/converters.js +3 -2
  25. package/dist/core.cjs +45 -2
  26. package/dist/core.d.cts +4 -3
  27. package/dist/core.d.ts +4 -3
  28. package/dist/core.js +5 -1
  29. package/dist/disconnectReason-IuADl6TH.d.cts +34 -0
  30. package/dist/disconnectReason-IuADl6TH.d.ts +34 -0
  31. package/dist/{dtos-DUpbIu8k.d.cts → dtos-Dd_fTfLn.d.cts} +26 -6
  32. package/dist/{dtos-DUpbIu8k.d.ts → dtos-Dd_fTfLn.d.ts} +26 -6
  33. package/dist/index.cjs +1089 -269
  34. package/dist/index.d.cts +16 -15
  35. package/dist/index.d.ts +16 -15
  36. package/dist/index.js +14 -8
  37. package/dist/linear.cjs +985 -53
  38. package/dist/linear.d.cts +137 -7
  39. package/dist/linear.d.ts +137 -7
  40. package/dist/linear.js +974 -53
  41. package/dist/mcp-claude.cjs +303 -32
  42. package/dist/mcp-claude.d.cts +3 -3
  43. package/dist/mcp-claude.d.ts +3 -3
  44. package/dist/mcp-claude.js +210 -12
  45. package/dist/mcp.cjs +313 -45
  46. package/dist/mcp.d.cts +5 -5
  47. package/dist/mcp.d.ts +5 -5
  48. package/dist/mcp.js +3 -3
  49. package/dist/{opencode-BBcDchcN.d.cts → opencode--iA5-KYk.d.cts} +2 -2
  50. package/dist/{opencode-DthQQUsZ.d.ts → opencode-YNacv-eJ.d.ts} +2 -2
  51. package/dist/{pagination-CcDkVFxK.d.ts → pagination-BBLsYLhT.d.ts} +2 -2
  52. package/dist/{pagination-BPiys10t.d.cts → pagination-CqidD-L_.d.cts} +2 -2
  53. package/dist/{protocols-DrhzOH6K.d.ts → protocols-BF6jamIl.d.ts} +1 -1
  54. package/dist/{protocols-CInhtFpA.d.cts → protocols-D2bTrQ_t.d.cts} +1 -1
  55. package/dist/rest.d.cts +5 -5
  56. package/dist/rest.d.ts +5 -5
  57. package/dist/runtime.cjs +721 -172
  58. package/dist/runtime.d.cts +15 -10
  59. package/dist/runtime.d.ts +15 -10
  60. package/dist/runtime.js +11 -8
  61. package/dist/{schemas-vos1AaBc.d.ts → schemas-B1Fd3oUM.d.ts} +17 -8
  62. package/dist/{schemas-BpEBkq5V.d.cts → schemas-CI0qgcp_.d.cts} +17 -8
  63. package/dist/{sdk-CcnQ5OUC.d.ts → sdk-CyqN1W5g.d.ts} +32 -2
  64. package/dist/{sdk-CwTAxhwI.d.cts → sdk-D2rTDU_o.d.cts} +32 -2
  65. package/dist/{simpleAdapter-DqhvjsGr.d.cts → simpleAdapter-C_f-01Cu.d.cts} +1 -1
  66. package/dist/{simpleAdapter-9OE_p6QW.d.ts → simpleAdapter-qQt-tSz4.d.ts} +1 -1
  67. package/dist/testing.d.cts +3 -3
  68. package/dist/testing.d.ts +3 -3
  69. package/dist/{types-CovcHpYf.d.cts → types-CKqrhGB1.d.cts} +2 -2
  70. package/dist/{types-CxII3XkA.d.ts → types-D3AsUnd0.d.ts} +1 -1
  71. package/dist/{types-7jVzOeOP.d.ts → types-DNySTI_8.d.ts} +2 -2
  72. package/dist/{types-CSHFipIc.d.cts → types-DtMms5Fi.d.cts} +1 -1
  73. package/package.json +22 -21
@@ -492,16 +492,15 @@ var import_node_crypto2 = require("crypto");
492
492
  var DEFAULT_PORT = 1e4;
493
493
  var DEFAULT_GATEWAY_URL = `http://localhost:${DEFAULT_PORT}`;
494
494
 
495
- // src/runtime/prompts.ts
496
- var BASE_INSTRUCTIONS = `
495
+ // src/runtime/prompts/base.ts
496
+ var ENVIRONMENT_SECTION = `
497
497
  ## Environment
498
498
 
499
499
  Multi-participant chat. Messages show sender: [Name]: content.
500
500
  Messages prefixed with [System]: are platform updates (participant changes, contact updates, etc.) \u2014 not messages from users.
501
501
  Use \`thenvoi_send_message(content, mentions)\` to respond. Plain text output is not delivered.
502
- Mentions use handles: @<username> for users, @<username>/<agent-name> for agents.
503
-
504
- ## CRITICAL: Delegate When You Cannot Help Directly
502
+ Mentions use handles: @<username> for users, @<username>/<agent-name> for agents.`;
503
+ var MULTI_AGENT_RULES_SECTION = `## CRITICAL: Delegate When You Cannot Help Directly
505
504
 
506
505
  You have NO internet access and NO real-time data. When asked about weather, news, stock prices,
507
506
  or any current information you cannot answer directly:
@@ -527,14 +526,12 @@ Only remove agents if the user explicitly requests it.
527
526
  When someone asks you to get information from another agent:
528
527
  1. Ask the other agent for the information
529
528
  2. When you receive the response, IMMEDIATELY relay it back to the ORIGINAL REQUESTER
530
- 3. Do NOT just thank the helper agent - the requester is waiting for their answer!
531
-
532
- ## IMPORTANT: Always Share Your Thinking
529
+ 3. Do NOT just thank the helper agent - the requester is waiting for their answer!`;
530
+ var THINKING_SECTION = `## IMPORTANT: Always Share Your Thinking
533
531
 
534
532
  You MUST call \`thenvoi_send_event(content, message_type="thought")\` BEFORE every action.
535
- This is required so users can see your reasoning process.
536
-
537
- ## Examples
533
+ This is required so users can see your reasoning process.`;
534
+ var EXAMPLES_SECTION = `## Examples
538
535
 
539
536
  ### Simple question - answer directly
540
537
  [John Doe]: What's 2+2?
@@ -567,8 +564,467 @@ This is required so users can see your reasoning process.
567
564
 
568
565
  [Weather Agent]: London is 8\xB0C and rainy.
569
566
  -> thenvoi_send_event("Got London weather. Relaying to John Doe.", message_type="thought")
570
- -> thenvoi_send_message("London is 8\xB0C and rainy.", mentions=["@john"])
571
- `;
567
+ -> thenvoi_send_message("London is 8\xB0C and rainy.", mentions=["@john"])`;
568
+ var BASE_INSTRUCTIONS = [
569
+ ENVIRONMENT_SECTION,
570
+ MULTI_AGENT_RULES_SECTION,
571
+ THINKING_SECTION,
572
+ EXAMPLES_SECTION
573
+ ].join("\n\n") + "\n";
574
+
575
+ // src/contracts/memory.ts
576
+ var SENSORY_MEMORY_TYPES = [
577
+ "iconic",
578
+ // Visual input
579
+ "echoic",
580
+ // Auditory input
581
+ "haptic"
582
+ // Tactile input
583
+ ];
584
+ var COGNITIVE_MEMORY_TYPES = [
585
+ "episodic",
586
+ // Events that occurred
587
+ "semantic",
588
+ // Facts, preferences, learned knowledge
589
+ "procedural"
590
+ // How to perform tasks
591
+ ];
592
+ function namedValues(values) {
593
+ return Object.fromEntries(values.map((value) => [value, value]));
594
+ }
595
+ var MEMORY_SYSTEM_TYPES = {
596
+ sensory: SENSORY_MEMORY_TYPES,
597
+ // Brief sensory inputs
598
+ working: COGNITIVE_MEMORY_TYPES,
599
+ // Short-term session context
600
+ long_term: COGNITIVE_MEMORY_TYPES
601
+ // Persistent cross-conversation memory
602
+ };
603
+ var MEMORY_SYSTEMS = Object.keys(MEMORY_SYSTEM_TYPES);
604
+ var MEMORY_TYPES = [
605
+ ...SENSORY_MEMORY_TYPES,
606
+ ...COGNITIVE_MEMORY_TYPES
607
+ ];
608
+ var MEMORY_SEGMENTS = [
609
+ "user",
610
+ // User preferences or profile info
611
+ "agent",
612
+ // Facts or events about agents/entities
613
+ "tool",
614
+ // Tool usage or task procedures
615
+ "guideline"
616
+ // Behavioral rules or policies
617
+ ];
618
+ var MEMORY_STORE_SCOPES = [
619
+ "subject",
620
+ // About one person/agent; requires subject_id
621
+ "organization"
622
+ // Shared org-wide
623
+ ];
624
+ var MEMORY_LIST_SCOPES = [
625
+ "subject",
626
+ // Subject-scoped memories only
627
+ "organization",
628
+ // Organization-scoped memories only
629
+ "all"
630
+ // Both scopes (no scope filter)
631
+ ];
632
+ var MEMORY_STATUSES = [
633
+ "active",
634
+ // Normal, visible memories
635
+ "superseded",
636
+ // Outdated; soft-deleted via thenvoi_supersede_memory
637
+ "archived",
638
+ // Hidden but preserved via thenvoi_archive_memory
639
+ "all"
640
+ // Any status (no filter)
641
+ ];
642
+ var MEMORY_SYSTEM = namedValues(MEMORY_SYSTEMS);
643
+ var MEMORY_TYPE = namedValues(MEMORY_TYPES);
644
+ var MEMORY_SEGMENT = namedValues(MEMORY_SEGMENTS);
645
+ var MEMORY_STORE_SCOPE = namedValues(MEMORY_STORE_SCOPES);
646
+
647
+ // src/contracts/chatEvents.ts
648
+ var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
649
+ var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
650
+
651
+ // src/runtime/tools/schemas.ts
652
+ var TOOL_MODELS = {
653
+ thenvoi_send_message: {
654
+ description: "Send a message to the chat room. Use this to respond to users or other agents. Messages require at least one @mention in the mentions array. You MUST use this tool to communicate \u2014 plain text responses won't reach users. When delegating, send the full task context in this message instead of assuming hidden state.",
655
+ properties: {
656
+ content: {
657
+ type: "string",
658
+ description: "The message content to send."
659
+ },
660
+ mentions: {
661
+ type: "array",
662
+ items: { type: "string" },
663
+ minItems: 1,
664
+ description: "List of participant handles to @mention. At least one required. For users: @<username> (e.g., '@john'). For agents: @<username>/<agent-name> (e.g., '@john/weather-agent'). Use the handle of someone already in the room."
665
+ }
666
+ },
667
+ required: ["content", "mentions"]
668
+ },
669
+ thenvoi_send_event: {
670
+ description: "Send an event to the chat room. No mentions required. 'thought': Share your reasoning or plan BEFORE taking actions. Explain what you're about to do and why. 'error': Report an error or problem that occurred. 'task': Report task progress or completion status. Always send a thought before complex actions to keep users informed.",
671
+ properties: {
672
+ content: {
673
+ type: "string",
674
+ description: "Human-readable event content."
675
+ },
676
+ message_type: {
677
+ type: "string",
678
+ enum: [...CHAT_EVENT_TYPES],
679
+ description: "Type of event."
680
+ },
681
+ metadata: {
682
+ type: "object",
683
+ description: "Optional structured data for the event."
684
+ }
685
+ },
686
+ required: ["content", "message_type"]
687
+ },
688
+ thenvoi_add_participant: {
689
+ description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use thenvoi_lookup_peers() first to find available agents. Pass the exact peer name from thenvoi_lookup_peers, not the handle. For normal delegation, omit role or use 'member'.",
690
+ properties: {
691
+ name: {
692
+ type: "string",
693
+ description: "Name of participant to add (must match a name from thenvoi_lookup_peers)."
694
+ },
695
+ role: {
696
+ type: "string",
697
+ enum: ["owner", "admin", "member"],
698
+ description: "Role for the participant in this room."
699
+ }
700
+ },
701
+ required: ["name"]
702
+ },
703
+ thenvoi_remove_participant: {
704
+ description: "Remove a participant from the chat room by name.",
705
+ properties: {
706
+ name: {
707
+ type: "string",
708
+ description: "Name of the participant to remove."
709
+ }
710
+ },
711
+ required: ["name"]
712
+ },
713
+ thenvoi_get_participants: {
714
+ description: "Get a list of all participants in the current chat room.",
715
+ properties: {},
716
+ required: []
717
+ },
718
+ thenvoi_lookup_peers: {
719
+ description: "List available peers (agents and users) that can be added to this room. Automatically excludes peers already in the room. Returns dict with 'peers' list and 'metadata' (page, page_size, total_count, total_pages). Use this to find specialized agents (e.g., Weather Agent) when you cannot answer a question directly.",
720
+ properties: {
721
+ page: {
722
+ type: "integer",
723
+ description: "Page number."
724
+ },
725
+ page_size: {
726
+ type: "integer",
727
+ description: "Items per page (max 100).",
728
+ maximum: 100
729
+ }
730
+ },
731
+ required: []
732
+ },
733
+ thenvoi_create_chatroom: {
734
+ description: "Create a new chat room for a specific task or conversation.",
735
+ properties: {
736
+ task_id: {
737
+ type: "string",
738
+ description: "Associated task ID (optional)."
739
+ }
740
+ },
741
+ required: []
742
+ },
743
+ thenvoi_list_contacts: {
744
+ description: "List agent's contacts with pagination.",
745
+ properties: {
746
+ page: {
747
+ type: "integer",
748
+ description: "Page number.",
749
+ minimum: 1
750
+ },
751
+ page_size: {
752
+ type: "integer",
753
+ description: "Items per page.",
754
+ minimum: 1,
755
+ maximum: 100
756
+ }
757
+ },
758
+ required: []
759
+ },
760
+ thenvoi_add_contact: {
761
+ description: "Send a contact request to add someone as a contact. Returns 'pending' when request is created. Returns 'approved' when inverse request existed and was auto-accepted.",
762
+ properties: {
763
+ handle: {
764
+ type: "string",
765
+ description: "Handle of user/agent to add (e.g., '@john' or '@john/agent-name')."
766
+ },
767
+ message: {
768
+ type: "string",
769
+ description: "Optional message with the request."
770
+ }
771
+ },
772
+ required: ["handle"]
773
+ },
774
+ thenvoi_remove_contact: {
775
+ description: "Remove an existing contact by handle or ID.",
776
+ properties: {
777
+ handle: {
778
+ type: "string",
779
+ description: "Contact's handle."
780
+ },
781
+ contact_id: {
782
+ type: "string",
783
+ description: "Or contact record ID (UUID)."
784
+ }
785
+ },
786
+ required: []
787
+ },
788
+ thenvoi_list_contact_requests: {
789
+ description: "List both received and sent contact requests. Received requests are always filtered to pending status. Sent requests can be filtered by status.",
790
+ properties: {
791
+ page: {
792
+ type: "integer",
793
+ description: "Page number.",
794
+ minimum: 1
795
+ },
796
+ page_size: {
797
+ type: "integer",
798
+ description: "Items per page per direction (max 100).",
799
+ minimum: 1,
800
+ maximum: 100
801
+ },
802
+ sent_status: {
803
+ type: "string",
804
+ enum: ["pending", "approved", "rejected", "cancelled", "all"],
805
+ description: "Filter sent requests by status."
806
+ }
807
+ },
808
+ required: []
809
+ },
810
+ thenvoi_respond_contact_request: {
811
+ description: "Respond to a contact request. 'approve'/'reject': For requests you RECEIVED (handle = requester's handle). 'cancel': For requests you SENT (handle = recipient's handle).",
812
+ properties: {
813
+ action: {
814
+ type: "string",
815
+ enum: ["approve", "reject", "cancel"],
816
+ description: "Action to take."
817
+ },
818
+ handle: {
819
+ type: "string",
820
+ description: "Other party's handle."
821
+ },
822
+ request_id: {
823
+ type: "string",
824
+ description: "Or request ID (UUID)."
825
+ }
826
+ },
827
+ required: ["action"]
828
+ },
829
+ thenvoi_list_memories: {
830
+ description: "List memories accessible to the agent. Returns memories about the specified subject (cross-agent sharing) and organization-wide shared memories.",
831
+ properties: {
832
+ subject_id: {
833
+ type: "string",
834
+ description: "Filter by subject UUID (required for subject-scoped queries)."
835
+ },
836
+ scope: {
837
+ type: "string",
838
+ enum: [...MEMORY_LIST_SCOPES],
839
+ description: "Filter by scope."
840
+ },
841
+ system: {
842
+ type: "string",
843
+ enum: [...MEMORY_SYSTEMS],
844
+ description: "Filter by memory system."
845
+ },
846
+ type: {
847
+ type: "string",
848
+ enum: [...MEMORY_TYPES],
849
+ description: "Filter by memory type."
850
+ },
851
+ segment: {
852
+ type: "string",
853
+ enum: [...MEMORY_SEGMENTS],
854
+ description: "Filter by segment."
855
+ },
856
+ content_query: {
857
+ type: "string",
858
+ description: "Full-text search query."
859
+ },
860
+ page_size: {
861
+ type: "integer",
862
+ description: "Number of results per page.",
863
+ minimum: 1,
864
+ maximum: 50
865
+ },
866
+ status: {
867
+ type: "string",
868
+ enum: [...MEMORY_STATUSES],
869
+ description: "Filter by status."
870
+ }
871
+ },
872
+ required: []
873
+ },
874
+ thenvoi_store_memory: {
875
+ description: "Store a new memory entry. The memory will be associated with the authenticated agent as the source. For subject-scoped memories, provide a subject_id. For organization-scoped memories, omit subject_id.",
876
+ properties: {
877
+ content: {
878
+ type: "string",
879
+ description: "The memory content."
880
+ },
881
+ system: {
882
+ type: "string",
883
+ enum: [...MEMORY_SYSTEMS],
884
+ description: "Memory system tier."
885
+ },
886
+ type: {
887
+ type: "string",
888
+ enum: [...MEMORY_TYPES],
889
+ description: "Memory type (must be valid for selected system)."
890
+ },
891
+ segment: {
892
+ type: "string",
893
+ enum: [...MEMORY_SEGMENTS],
894
+ description: "Logical segment."
895
+ },
896
+ thought: {
897
+ type: "string",
898
+ description: "Agent's reasoning for storing this memory."
899
+ },
900
+ scope: {
901
+ type: "string",
902
+ enum: [...MEMORY_STORE_SCOPES],
903
+ description: "Visibility scope."
904
+ },
905
+ subject_id: {
906
+ type: "string",
907
+ description: "UUID of the subject this memory is about (required for subject scope)."
908
+ },
909
+ metadata: {
910
+ type: "object",
911
+ description: "Additional metadata (tags, references)."
912
+ }
913
+ },
914
+ required: ["content", "system", "type", "segment", "thought"]
915
+ },
916
+ thenvoi_get_memory: {
917
+ description: "Retrieve a specific memory by ID.",
918
+ properties: {
919
+ memory_id: {
920
+ type: "string",
921
+ description: "Memory ID (UUID)."
922
+ }
923
+ },
924
+ required: ["memory_id"]
925
+ },
926
+ thenvoi_supersede_memory: {
927
+ description: "Mark a memory as superseded (soft delete). Use when information is outdated or incorrect. The memory remains for audit trail but won't appear in normal queries. Only the source agent can supersede.",
928
+ properties: {
929
+ memory_id: {
930
+ type: "string",
931
+ description: "Memory ID (UUID)."
932
+ }
933
+ },
934
+ required: ["memory_id"]
935
+ },
936
+ thenvoi_archive_memory: {
937
+ description: "Archive a memory (hide but preserve). Use when memory is valid but not currently needed. Archived memories can be restored later by humans. Only the source agent can archive.",
938
+ properties: {
939
+ memory_id: {
940
+ type: "string",
941
+ description: "Memory ID (UUID)."
942
+ }
943
+ },
944
+ required: ["memory_id"]
945
+ }
946
+ };
947
+ var ALL_TOOL_NAMES = new Set(Object.keys(TOOL_MODELS));
948
+ var MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set([
949
+ "thenvoi_list_memories",
950
+ "thenvoi_store_memory",
951
+ "thenvoi_get_memory",
952
+ "thenvoi_supersede_memory",
953
+ "thenvoi_archive_memory"
954
+ ]);
955
+ var CONTACT_TOOL_NAMES = /* @__PURE__ */ new Set([
956
+ "thenvoi_list_contacts",
957
+ "thenvoi_add_contact",
958
+ "thenvoi_remove_contact",
959
+ "thenvoi_list_contact_requests",
960
+ "thenvoi_respond_contact_request"
961
+ ]);
962
+ var BASE_TOOL_NAMES = new Set(
963
+ [...ALL_TOOL_NAMES].filter((name) => !MEMORY_TOOL_NAMES.has(name))
964
+ );
965
+ var CHAT_TOOL_NAMES = new Set(
966
+ [...BASE_TOOL_NAMES].filter((name) => !CONTACT_TOOL_NAMES.has(name))
967
+ );
968
+
969
+ // src/runtime/prompts/memory.ts
970
+ var MEMORY_INTRO = `## Memory Tools
971
+
972
+ You have access to memory tools for storing and retrieving information
973
+ across conversations. Use \`thenvoi_store_memory\` to persist important
974
+ information and \`thenvoi_list_memories\` / \`thenvoi_get_memory\` to recall it.
975
+ Use \`thenvoi_supersede_memory\` to mark outdated memories and
976
+ \`thenvoi_archive_memory\` to hide memories that should be preserved.`;
977
+ function longTermPattern(label, type, segment, scope) {
978
+ return {
979
+ label,
980
+ system: MEMORY_SYSTEM.long_term,
981
+ type,
982
+ segment,
983
+ scope
984
+ };
985
+ }
986
+ var COMMON_MEMORY_PATTERNS = [
987
+ longTermPattern("Facts learned about a specific agent/entity", MEMORY_TYPE.semantic, MEMORY_SEGMENT.agent, MEMORY_STORE_SCOPE.subject),
988
+ longTermPattern("Events involving a specific person/agent", MEMORY_TYPE.episodic, MEMORY_SEGMENT.agent, MEMORY_STORE_SCOPE.subject),
989
+ longTermPattern("A user's preferences or profile info", MEMORY_TYPE.semantic, MEMORY_SEGMENT.user, MEMORY_STORE_SCOPE.subject),
990
+ longTermPattern("Org-wide knowledge or how to perform a task", MEMORY_TYPE.procedural, MEMORY_SEGMENT.tool, MEMORY_STORE_SCOPE.organization)
991
+ ];
992
+ function renderMemoryPattern(pattern) {
993
+ return `- ${pattern.label}: \`system="${pattern.system}"\`, \`type="${pattern.type}"\`, \`segment="${pattern.segment}"\`, \`scope="${pattern.scope}"\``;
994
+ }
995
+ var MEMORY_COMMON_PATTERNS = [
996
+ "Common patterns:",
997
+ ...COMMON_MEMORY_PATTERNS.map(renderMemoryPattern)
998
+ ].join("\n");
999
+ var MEMORY_SCOPE_GUIDANCE = `Prefer \`scope="${MEMORY_STORE_SCOPE.subject}"\` whenever the memory is about a specific person or agent, so it
1000
+ stays attached to that subject rather than leaking org-wide. Storing with \`scope="${MEMORY_STORE_SCOPE.subject}"\` requires a
1001
+ real \`subject_id\` UUID, so resolve it first via \`thenvoi_lookup_peers\` or the participant list.
1002
+ Reserve \`scope="${MEMORY_STORE_SCOPE.organization}"\` for knowledge that is genuinely shared across the whole organization and
1003
+ is not about any one subject.`;
1004
+ function quoteChoices(values) {
1005
+ return values.map((value) => `\`"${value}"\``).join(" | ");
1006
+ }
1007
+ function memoryTypeLines() {
1008
+ return Object.entries(MEMORY_SYSTEM_TYPES).map(([system, types]) => ` - ${system}: ${quoteChoices(types)}`).join("\n");
1009
+ }
1010
+ function buildMemorySection() {
1011
+ const storeMemoryProps = TOOL_MODELS.thenvoi_store_memory.properties;
1012
+ const systems = storeMemoryProps.system.enum;
1013
+ const segments = storeMemoryProps.segment.enum;
1014
+ const scopes = storeMemoryProps.scope.enum;
1015
+ const fieldRules = `When calling \`thenvoi_store_memory\`, the \`system\`, \`type\`, \`segment\`, and \`scope\` fields
1016
+ must use these exact values (case-sensitive):
1017
+
1018
+ - **system**: ${quoteChoices(systems)}
1019
+ - **type** (must match the chosen system):
1020
+ ${memoryTypeLines()}
1021
+ - **segment**: ${quoteChoices(segments)}
1022
+ - **scope**: ${quoteChoices(scopes)}`;
1023
+ return [MEMORY_INTRO, fieldRules, MEMORY_COMMON_PATTERNS, MEMORY_SCOPE_GUIDANCE].join("\n\n");
1024
+ }
1025
+ var MEMORY_SECTION = buildMemorySection();
1026
+
1027
+ // src/runtime/prompts/templates.ts
572
1028
  var TEMPLATES = {
573
1029
  default: `You are {agent_name}, {agent_description}.
574
1030
 
@@ -1,8 +1,8 @@
1
- export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-BdRz9_UN.cjs';
2
- import { H as HistoryConverter } from './protocols-CInhtFpA.cjs';
3
- export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode-BBcDchcN.cjs';
4
- import './dtos-DUpbIu8k.cjs';
5
- import './types-CSHFipIc.cjs';
1
+ export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-CUBXIiG6.cjs';
2
+ import { H as HistoryConverter } from './protocols-D2bTrQ_t.cjs';
3
+ export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode--iA5-KYk.cjs';
4
+ import './dtos-Dd_fTfLn.cjs';
5
+ import './types-DtMms5Fi.cjs';
6
6
 
7
7
  type VercelAISDKMessage = {
8
8
  role: "system";
@@ -1,8 +1,8 @@
1
- export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-B1Da7L6u.js';
2
- import { H as HistoryConverter } from './protocols-DrhzOH6K.js';
3
- export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode-DthQQUsZ.js';
4
- import './dtos-DUpbIu8k.js';
5
- import './types-CxII3XkA.js';
1
+ export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-NZAeg-WO.js';
2
+ import { H as HistoryConverter } from './protocols-BF6jamIl.js';
3
+ export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode-YNacv-eJ.js';
4
+ import './dtos-Dd_fTfLn.js';
5
+ import './types-D3AsUnd0.js';
6
6
 
7
7
  type VercelAISDKMessage = {
8
8
  role: "system";
@@ -18,9 +18,10 @@ import {
18
18
  parseDate,
19
19
  parseToolCall,
20
20
  parseToolResult
21
- } from "./chunk-W5NDZSYE.js";
21
+ } from "./chunk-XA4N2JPH.js";
22
22
  import "./chunk-AVVDPXP4.js";
23
- import "./chunk-SFVKOEQH.js";
23
+ import "./chunk-DNPVCR3S.js";
24
+ import "./chunk-MLROFDKR.js";
24
25
  import "./chunk-ZZJRRBPQ.js";
25
26
  import "./chunk-3BKAC4OZ.js";
26
27
  import "./chunk-OD2G5LFQ.js";
package/dist/core.cjs CHANGED
@@ -27,7 +27,8 @@ __export(core_exports, {
27
27
  ThenvoiSdkError: () => ThenvoiSdkError,
28
28
  TransportError: () => TransportError,
29
29
  UnsupportedFeatureError: () => UnsupportedFeatureError,
30
- ValidationError: () => ValidationError
30
+ ValidationError: () => ValidationError,
31
+ WebSocketDisconnectError: () => WebSocketDisconnectError
31
32
  });
32
33
  module.exports = __toCommonJS(core_exports);
33
34
 
@@ -99,6 +100,47 @@ var RuntimeStateError = class extends ThenvoiSdkError {
99
100
  }
100
101
  };
101
102
 
103
+ // src/platform/streaming/disconnectReason.ts
104
+ var import_zod = require("zod");
105
+ var UPGRADE_CODES = [
106
+ "invalid_on_conflict",
107
+ "connection_conflict",
108
+ "too_many_requests",
109
+ "tracking_failed"
110
+ ];
111
+ var upgradeErrorSchema = import_zod.z.object({
112
+ status: import_zod.z.number(),
113
+ body: import_zod.z.preprocess(
114
+ (body) => {
115
+ if (typeof body !== "string") {
116
+ return body;
117
+ }
118
+ try {
119
+ return JSON.parse(body);
120
+ } catch {
121
+ return null;
122
+ }
123
+ },
124
+ import_zod.z.object({
125
+ error: import_zod.z.object({
126
+ code: import_zod.z.enum(UPGRADE_CODES),
127
+ message: import_zod.z.string().optional(),
128
+ retry_after: import_zod.z.number().nullable().optional(),
129
+ request_id: import_zod.z.string().nullable().optional()
130
+ })
131
+ })
132
+ ),
133
+ headers: import_zod.z.record(import_zod.z.unknown()).optional()
134
+ });
135
+ var WebSocketDisconnectError = class extends Error {
136
+ reason;
137
+ constructor(reason) {
138
+ super(reason.message);
139
+ this.name = "WebSocketDisconnectError";
140
+ this.reason = reason;
141
+ }
142
+ };
143
+
102
144
  // src/core/logger.ts
103
145
  var noop = () => void 0;
104
146
  var REDACTED_VALUE = "[REDACTED]";
@@ -181,5 +223,6 @@ function sanitizeValue(value, seen = /* @__PURE__ */ new WeakSet()) {
181
223
  ThenvoiSdkError,
182
224
  TransportError,
183
225
  UnsupportedFeatureError,
184
- ValidationError
226
+ ValidationError,
227
+ WebSocketDisconnectError
185
228
  });
package/dist/core.d.cts CHANGED
@@ -1,7 +1,8 @@
1
- export { S as SimpleAdapter } from './simpleAdapter-DqhvjsGr.cjs';
2
- export { A as AdapterToolsProtocol, a as AgentToolsProtocol, C as ContactTools, F as FrameworkAdapter, b as FrameworkAdapterInput, H as HistoryConverter, M as MemoryTools, c as MessagingTools, P as ParticipantTools, d as PeerLookupTools, e as Preprocessor, R as RoomParticipantTools, T as ToolExecutor, f as ToolSchemaProvider } from './protocols-CInhtFpA.cjs';
1
+ export { S as SimpleAdapter } from './simpleAdapter-C_f-01Cu.cjs';
2
+ export { A as AdapterToolsProtocol, a as AgentToolsProtocol, C as ContactTools, F as FrameworkAdapter, b as FrameworkAdapterInput, H as HistoryConverter, M as MemoryTools, c as MessagingTools, P as ParticipantTools, d as PeerLookupTools, e as Preprocessor, R as RoomParticipantTools, T as ToolExecutor, f as ToolSchemaProvider } from './protocols-D2bTrQ_t.cjs';
3
+ export { W as WebSocketConflictPolicy, a as WebSocketDisconnectError, b as WebSocketDisconnectReason } from './disconnectReason-IuADl6TH.cjs';
3
4
  export { C as ConsoleLogger, L as Logger, N as NoopLogger } from './logger-CABQOnlR.cjs';
4
- import './dtos-DUpbIu8k.cjs';
5
+ import './dtos-Dd_fTfLn.cjs';
5
6
 
6
7
  declare class ThenvoiSdkError extends Error {
7
8
  constructor(message: string, cause?: unknown);
package/dist/core.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { S as SimpleAdapter } from './simpleAdapter-9OE_p6QW.js';
2
- export { A as AdapterToolsProtocol, a as AgentToolsProtocol, C as ContactTools, F as FrameworkAdapter, b as FrameworkAdapterInput, H as HistoryConverter, M as MemoryTools, c as MessagingTools, P as ParticipantTools, d as PeerLookupTools, e as Preprocessor, R as RoomParticipantTools, T as ToolExecutor, f as ToolSchemaProvider } from './protocols-DrhzOH6K.js';
1
+ export { S as SimpleAdapter } from './simpleAdapter-qQt-tSz4.js';
2
+ export { A as AdapterToolsProtocol, a as AgentToolsProtocol, C as ContactTools, F as FrameworkAdapter, b as FrameworkAdapterInput, H as HistoryConverter, M as MemoryTools, c as MessagingTools, P as ParticipantTools, d as PeerLookupTools, e as Preprocessor, R as RoomParticipantTools, T as ToolExecutor, f as ToolSchemaProvider } from './protocols-BF6jamIl.js';
3
+ export { W as WebSocketConflictPolicy, a as WebSocketDisconnectError, b as WebSocketDisconnectReason } from './disconnectReason-IuADl6TH.js';
3
4
  export { C as ConsoleLogger, L as Logger, N as NoopLogger } from './logger-CABQOnlR.js';
4
- import './dtos-DUpbIu8k.js';
5
+ import './dtos-Dd_fTfLn.js';
5
6
 
6
7
  declare class ThenvoiSdkError extends Error {
7
8
  constructor(message: string, cause?: unknown);
package/dist/core.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  SimpleAdapter
3
3
  } from "./chunk-AVVDPXP4.js";
4
+ import {
5
+ WebSocketDisconnectError
6
+ } from "./chunk-US226AS4.js";
4
7
  import {
5
8
  ConsoleLogger,
6
9
  NoopLogger
@@ -20,5 +23,6 @@ export {
20
23
  ThenvoiSdkError,
21
24
  TransportError,
22
25
  UnsupportedFeatureError,
23
- ValidationError
26
+ ValidationError,
27
+ WebSocketDisconnectError
24
28
  };