capacitor-native-agent 0.9.3 → 0.9.5

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.
@@ -281,7 +281,7 @@ private func makeRustCall<T, E: Swift.Error>(
281
281
  _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
282
282
  errorHandler: ((RustBuffer) throws -> E)?
283
283
  ) throws -> T {
284
- uniffiEnsureInitialized()
284
+ uniffiEnsureNativeAgentFfiInitialized()
285
285
  var callStatus = RustCallStatus.init()
286
286
  let returnedVal = callback(&callStatus)
287
287
  try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
@@ -352,20 +352,31 @@ private func uniffiTraitInterfaceCallWithError<T, E>(
352
352
  callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
353
353
  }
354
354
  }
355
- fileprivate class UniffiHandleMap<T> {
356
- private var map: [UInt64: T] = [:]
355
+ // Initial value and increment amount for handles.
356
+ // These ensure that SWIFT handles always have the lowest bit set
357
+ fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1
358
+ fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2
359
+
360
+ fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
361
+ // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
357
362
  private let lock = NSLock()
358
- private var currentHandle: UInt64 = 1
363
+ private var map: [UInt64: T] = [:]
364
+ private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL
359
365
 
360
366
  func insert(obj: T) -> UInt64 {
361
367
  lock.withLock {
362
- let handle = currentHandle
363
- currentHandle += 1
364
- map[handle] = obj
365
- return handle
368
+ return doInsert(obj)
366
369
  }
367
370
  }
368
371
 
372
+ // Low-level insert function, this assumes `lock` is held.
373
+ private func doInsert(_ obj: T) -> UInt64 {
374
+ let handle = currentHandle
375
+ currentHandle += UNIFFI_HANDLEMAP_DELTA
376
+ map[handle] = obj
377
+ return handle
378
+ }
379
+
369
380
  func get(handle: UInt64) throws -> T {
370
381
  try lock.withLock {
371
382
  guard let obj = map[handle] else {
@@ -375,6 +386,15 @@ fileprivate class UniffiHandleMap<T> {
375
386
  }
376
387
  }
377
388
 
389
+ func clone(handle: UInt64) throws -> UInt64 {
390
+ try lock.withLock {
391
+ guard let obj = map[handle] else {
392
+ throw UniffiInternalError.unexpectedStaleHandle
393
+ }
394
+ return doInsert(obj)
395
+ }
396
+ }
397
+
378
398
  @discardableResult
379
399
  func remove(handle: UInt64) throws -> T {
380
400
  try lock.withLock {
@@ -394,7 +414,13 @@ fileprivate class UniffiHandleMap<T> {
394
414
 
395
415
 
396
416
  // Public interface members begin here.
397
-
417
+ // Magic number for the Rust proxy to call using the same mechanism as every other method,
418
+ // to free the callback once it's dropped by Rust.
419
+ private let IDX_CALLBACK_FREE: Int32 = 0
420
+ // Callback return codes
421
+ private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
422
+ private let UNIFFI_CALLBACK_ERROR: Int32 = 1
423
+ private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
398
424
 
399
425
  #if swift(>=5.8)
400
426
  @_documentation(visibility: private)
@@ -499,7 +525,7 @@ fileprivate struct FfiConverterString: FfiConverter {
499
525
  /**
500
526
  * Long-lived handle — one per app lifecycle.
501
527
  */
502
- public protocol NativeAgentHandleProtocol : AnyObject {
528
+ public protocol NativeAgentHandleProtocol: AnyObject, Sendable {
503
529
 
504
530
  /**
505
531
  * Abort the current agent turn.
@@ -528,6 +554,19 @@ public protocol NativeAgentHandleProtocol : AnyObject {
528
554
  */
529
555
  func deleteAuth(provider: String) throws
530
556
 
557
+ /**
558
+ * Parse a canonical `wire::AgentCommand` JSON string, dispatch to the
559
+ * matching internal method, and return the JSON-encoded
560
+ * `wire::CommandAck`. The boundary is JSON strings only — see the
561
+ * wire module docs for shape details.
562
+ *
563
+ * `ListSessions` and `ResumeSession` commands assume agent_id `"main"`
564
+ * (aigenthive runs one agent per pod). Hosts that need a different
565
+ * agent_id should call `list_sessions(agent_id)` / `resume_session(...)`
566
+ * directly.
567
+ */
568
+ func dispatchAgentCommandJson(json: String) throws -> String
569
+
531
570
  /**
532
571
  * End a skill session.
533
572
  */
@@ -588,6 +627,13 @@ public protocol NativeAgentHandleProtocol : AnyObject {
588
627
  */
589
628
  func listCronRuns(jobId: String?, limit: Int64) throws -> String
590
629
 
630
+ /**
631
+ * Return the embedded native tool catalog. Hosts use this to seed
632
+ * permissions UI / tables on first run, and to check that local
633
+ * callers stay in sync with the FFI's known tools.
634
+ */
635
+ func listNativeTools() -> [NativeToolDescriptor]
636
+
591
637
  /**
592
638
  * List sessions for an agent.
593
639
  */
@@ -677,6 +723,13 @@ public protocol NativeAgentHandleProtocol : AnyObject {
677
723
  */
678
724
  func sendMessage(params: SendMessageParams) throws -> String
679
725
 
726
+ /**
727
+ * Build a canonical `wire::AgentEvent` JSON envelope from the raw
728
+ * event-type + payload pair the agent loop emits, stamping a fresh
729
+ * `received_at`. Hosts call this to produce wire bytes for AMQP/STOMP.
730
+ */
731
+ func serializeAgentEventJson(eventType: String, payloadJson: String, sessionKey: String?) throws -> String
732
+
680
733
  /**
681
734
  * Set an auth key for a provider.
682
735
  */
@@ -738,66 +791,68 @@ public protocol NativeAgentHandleProtocol : AnyObject {
738
791
  func updateSkill(id: String, patchJson: String) throws
739
792
 
740
793
  }
741
-
742
794
  /**
743
795
  * Long-lived handle — one per app lifecycle.
744
796
  */
745
- open class NativeAgentHandle:
746
- NativeAgentHandleProtocol {
747
- fileprivate let pointer: UnsafeMutableRawPointer!
797
+ open class NativeAgentHandle: NativeAgentHandleProtocol, @unchecked Sendable {
798
+ fileprivate let handle: UInt64
748
799
 
749
- /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
800
+ /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
750
801
  #if swift(>=5.8)
751
802
  @_documentation(visibility: private)
752
803
  #endif
753
- public struct NoPointer {
804
+ public struct NoHandle {
754
805
  public init() {}
755
806
  }
756
807
 
757
808
  // TODO: We'd like this to be `private` but for Swifty reasons,
758
809
  // we can't implement `FfiConverter` without making this `required` and we can't
759
810
  // make it `required` without making it `public`.
760
- required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
761
- self.pointer = pointer
811
+ #if swift(>=5.8)
812
+ @_documentation(visibility: private)
813
+ #endif
814
+ required public init(unsafeFromHandle handle: UInt64) {
815
+ self.handle = handle
762
816
  }
763
817
 
764
818
  // This constructor can be used to instantiate a fake object.
765
- // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
819
+ // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
766
820
  //
767
821
  // - Warning:
768
- // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
822
+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
769
823
  #if swift(>=5.8)
770
824
  @_documentation(visibility: private)
771
825
  #endif
772
- public init(noPointer: NoPointer) {
773
- self.pointer = nil
826
+ public init(noHandle: NoHandle) {
827
+ self.handle = 0
774
828
  }
775
829
 
776
830
  #if swift(>=5.8)
777
831
  @_documentation(visibility: private)
778
832
  #endif
779
- public func uniffiClonePointer() -> UnsafeMutableRawPointer {
780
- return try! rustCall { uniffi_native_agent_ffi_fn_clone_nativeagenthandle(self.pointer, $0) }
833
+ public func uniffiCloneHandle() -> UInt64 {
834
+ return try! rustCall { uniffi_native_agent_ffi_fn_clone_nativeagenthandle(self.handle, $0) }
781
835
  }
782
836
  /**
783
837
  * Create a new native agent handle.
784
838
  */
785
839
  public convenience init(config: InitConfig)throws {
786
- let pointer =
787
- try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
840
+ let handle =
841
+ try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
788
842
  uniffi_native_agent_ffi_fn_constructor_nativeagenthandle_new(
789
- FfiConverterTypeInitConfig.lower(config),$0
843
+ FfiConverterTypeInitConfig_lower(config),$0
790
844
  )
791
845
  }
792
- self.init(unsafeFromRawPointer: pointer)
846
+ self.init(unsafeFromHandle: handle)
793
847
  }
794
848
 
795
849
  deinit {
796
- guard let pointer = pointer else {
850
+ if handle == 0 {
851
+ // Mock objects have handle=0 don't try to free them
797
852
  return
798
853
  }
799
854
 
800
- try! rustCall { uniffi_native_agent_ffi_fn_free_nativeagenthandle(pointer, $0) }
855
+ try! rustCall { uniffi_native_agent_ffi_fn_free_nativeagenthandle(handle, $0) }
801
856
  }
802
857
 
803
858
 
@@ -806,8 +861,9 @@ public convenience init(config: InitConfig)throws {
806
861
  /**
807
862
  * Abort the current agent turn.
808
863
  */
809
- open func abort()throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
810
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_abort(self.uniffiClonePointer(),$0
864
+ open func abort()throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
865
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_abort(
866
+ self.uniffiCloneHandle(),$0
811
867
  )
812
868
  }
813
869
  }
@@ -815,9 +871,10 @@ open func abort()throws {try rustCallWithError(FfiConverterTypeNativeAgentError
815
871
  /**
816
872
  * Add a cron job.
817
873
  */
818
- open func addCronJob(inputJson: String)throws -> String {
819
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
820
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_cron_job(self.uniffiClonePointer(),
874
+ open func addCronJob(inputJson: String)throws -> String {
875
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
876
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_cron_job(
877
+ self.uniffiCloneHandle(),
821
878
  FfiConverterString.lower(inputJson),$0
822
879
  )
823
880
  })
@@ -826,9 +883,10 @@ open func addCronJob(inputJson: String)throws -> String {
826
883
  /**
827
884
  * Add a cron skill.
828
885
  */
829
- open func addSkill(inputJson: String)throws -> String {
830
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
831
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_skill(self.uniffiClonePointer(),
886
+ open func addSkill(inputJson: String)throws -> String {
887
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
888
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_skill(
889
+ self.uniffiCloneHandle(),
832
890
  FfiConverterString.lower(inputJson),$0
833
891
  )
834
892
  })
@@ -839,8 +897,9 @@ open func addSkill(inputJson: String)throws -> String {
839
897
  * starts a fresh conversation. The session row in SQLite is preserved
840
898
  * so it remains in the session index for later resume/switch.
841
899
  */
842
- open func clearSession()throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
843
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_clear_session(self.uniffiClonePointer(),$0
900
+ open func clearSession()throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
901
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_clear_session(
902
+ self.uniffiCloneHandle(),$0
844
903
  )
845
904
  }
846
905
  }
@@ -848,18 +907,40 @@ open func clearSession()throws {try rustCallWithError(FfiConverterTypeNativeAge
848
907
  /**
849
908
  * Delete auth for a provider.
850
909
  */
851
- open func deleteAuth(provider: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
852
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_delete_auth(self.uniffiClonePointer(),
910
+ open func deleteAuth(provider: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
911
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_delete_auth(
912
+ self.uniffiCloneHandle(),
853
913
  FfiConverterString.lower(provider),$0
854
914
  )
855
915
  }
916
+ }
917
+
918
+ /**
919
+ * Parse a canonical `wire::AgentCommand` JSON string, dispatch to the
920
+ * matching internal method, and return the JSON-encoded
921
+ * `wire::CommandAck`. The boundary is JSON strings only — see the
922
+ * wire module docs for shape details.
923
+ *
924
+ * `ListSessions` and `ResumeSession` commands assume agent_id `"main"`
925
+ * (aigenthive runs one agent per pod). Hosts that need a different
926
+ * agent_id should call `list_sessions(agent_id)` / `resume_session(...)`
927
+ * directly.
928
+ */
929
+ open func dispatchAgentCommandJson(json: String)throws -> String {
930
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
931
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_dispatch_agent_command_json(
932
+ self.uniffiCloneHandle(),
933
+ FfiConverterString.lower(json),$0
934
+ )
935
+ })
856
936
  }
857
937
 
858
938
  /**
859
939
  * End a skill session.
860
940
  */
861
- open func endSkill(skillId: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
862
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_end_skill(self.uniffiClonePointer(),
941
+ open func endSkill(skillId: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
942
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_end_skill(
943
+ self.uniffiCloneHandle(),
863
944
  FfiConverterString.lower(skillId),$0
864
945
  )
865
946
  }
@@ -868,9 +949,10 @@ open func endSkill(skillId: String)throws {try rustCallWithError(FfiConverterTy
868
949
  /**
869
950
  * Exchange an OAuth authorization code for tokens.
870
951
  */
871
- open func exchangeOauthCode(tokenUrl: String, bodyJson: String, contentType: String?)throws -> String {
872
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
873
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_exchange_oauth_code(self.uniffiClonePointer(),
952
+ open func exchangeOauthCode(tokenUrl: String, bodyJson: String, contentType: String?)throws -> String {
953
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
954
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_exchange_oauth_code(
955
+ self.uniffiCloneHandle(),
874
956
  FfiConverterString.lower(tokenUrl),
875
957
  FfiConverterString.lower(bodyJson),
876
958
  FfiConverterOptionString.lower(contentType),$0
@@ -881,8 +963,9 @@ open func exchangeOauthCode(tokenUrl: String, bodyJson: String, contentType: Str
881
963
  /**
882
964
  * Follow up on the current conversation.
883
965
  */
884
- open func followUp(prompt: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
885
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_follow_up(self.uniffiClonePointer(),
966
+ open func followUp(prompt: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
967
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_follow_up(
968
+ self.uniffiCloneHandle(),
886
969
  FfiConverterString.lower(prompt),$0
887
970
  )
888
971
  }
@@ -891,9 +974,10 @@ open func followUp(prompt: String)throws {try rustCallWithError(FfiConverterTyp
891
974
  /**
892
975
  * Get auth status (masked key).
893
976
  */
894
- open func getAuthStatus(provider: String)throws -> AuthStatusResult {
895
- return try FfiConverterTypeAuthStatusResult.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
896
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_status(self.uniffiClonePointer(),
977
+ open func getAuthStatus(provider: String)throws -> AuthStatusResult {
978
+ return try FfiConverterTypeAuthStatusResult_lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
979
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_status(
980
+ self.uniffiCloneHandle(),
897
981
  FfiConverterString.lower(provider),$0
898
982
  )
899
983
  })
@@ -902,9 +986,10 @@ open func getAuthStatus(provider: String)throws -> AuthStatusResult {
902
986
  /**
903
987
  * Get auth token for a provider.
904
988
  */
905
- open func getAuthToken(provider: String)throws -> AuthTokenResult {
906
- return try FfiConverterTypeAuthTokenResult.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
907
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_token(self.uniffiClonePointer(),
989
+ open func getAuthToken(provider: String)throws -> AuthTokenResult {
990
+ return try FfiConverterTypeAuthTokenResult_lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
991
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_token(
992
+ self.uniffiCloneHandle(),
908
993
  FfiConverterString.lower(provider),$0
909
994
  )
910
995
  })
@@ -913,9 +998,10 @@ open func getAuthToken(provider: String)throws -> AuthTokenResult {
913
998
  /**
914
999
  * Get heartbeat config.
915
1000
  */
916
- open func getHeartbeatConfig()throws -> String {
917
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
918
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_heartbeat_config(self.uniffiClonePointer(),$0
1001
+ open func getHeartbeatConfig()throws -> String {
1002
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1003
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_heartbeat_config(
1004
+ self.uniffiCloneHandle(),$0
919
1005
  )
920
1006
  })
921
1007
  }
@@ -923,9 +1009,10 @@ open func getHeartbeatConfig()throws -> String {
923
1009
  /**
924
1010
  * Get available models for a provider.
925
1011
  */
926
- open func getModels(provider: String)throws -> String {
927
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
928
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_models(self.uniffiClonePointer(),
1012
+ open func getModels(provider: String)throws -> String {
1013
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1014
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_models(
1015
+ self.uniffiCloneHandle(),
929
1016
  FfiConverterString.lower(provider),$0
930
1017
  )
931
1018
  })
@@ -934,9 +1021,10 @@ open func getModels(provider: String)throws -> String {
934
1021
  /**
935
1022
  * Get scheduler config.
936
1023
  */
937
- open func getSchedulerConfig()throws -> String {
938
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
939
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_scheduler_config(self.uniffiClonePointer(),$0
1024
+ open func getSchedulerConfig()throws -> String {
1025
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1026
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_scheduler_config(
1027
+ self.uniffiCloneHandle(),$0
940
1028
  )
941
1029
  })
942
1030
  }
@@ -944,8 +1032,9 @@ open func getSchedulerConfig()throws -> String {
944
1032
  /**
945
1033
  * Handle a wake event (evaluate due cron jobs).
946
1034
  */
947
- open func handleWake(source: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
948
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_handle_wake(self.uniffiClonePointer(),
1035
+ open func handleWake(source: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1036
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_handle_wake(
1037
+ self.uniffiCloneHandle(),
949
1038
  FfiConverterString.lower(source),$0
950
1039
  )
951
1040
  }
@@ -954,9 +1043,10 @@ open func handleWake(source: String)throws {try rustCallWithError(FfiConverterT
954
1043
  /**
955
1044
  * Invoke a tool directly.
956
1045
  */
957
- open func invokeTool(toolName: String, argsJson: String)throws -> String {
958
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
959
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_invoke_tool(self.uniffiClonePointer(),
1046
+ open func invokeTool(toolName: String, argsJson: String)throws -> String {
1047
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1048
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_invoke_tool(
1049
+ self.uniffiCloneHandle(),
960
1050
  FfiConverterString.lower(toolName),
961
1051
  FfiConverterString.lower(argsJson),$0
962
1052
  )
@@ -966,9 +1056,10 @@ open func invokeTool(toolName: String, argsJson: String)throws -> String {
966
1056
  /**
967
1057
  * List all cron jobs.
968
1058
  */
969
- open func listCronJobs()throws -> String {
970
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
971
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_jobs(self.uniffiClonePointer(),$0
1059
+ open func listCronJobs()throws -> String {
1060
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1061
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_jobs(
1062
+ self.uniffiCloneHandle(),$0
972
1063
  )
973
1064
  })
974
1065
  }
@@ -976,21 +1067,36 @@ open func listCronJobs()throws -> String {
976
1067
  /**
977
1068
  * List cron run history.
978
1069
  */
979
- open func listCronRuns(jobId: String?, limit: Int64)throws -> String {
980
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
981
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_runs(self.uniffiClonePointer(),
1070
+ open func listCronRuns(jobId: String?, limit: Int64)throws -> String {
1071
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1072
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_runs(
1073
+ self.uniffiCloneHandle(),
982
1074
  FfiConverterOptionString.lower(jobId),
983
1075
  FfiConverterInt64.lower(limit),$0
984
1076
  )
985
1077
  })
1078
+ }
1079
+
1080
+ /**
1081
+ * Return the embedded native tool catalog. Hosts use this to seed
1082
+ * permissions UI / tables on first run, and to check that local
1083
+ * callers stay in sync with the FFI's known tools.
1084
+ */
1085
+ open func listNativeTools() -> [NativeToolDescriptor] {
1086
+ return try! FfiConverterSequenceTypeNativeToolDescriptor.lift(try! rustCall() {
1087
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_native_tools(
1088
+ self.uniffiCloneHandle(),$0
1089
+ )
1090
+ })
986
1091
  }
987
1092
 
988
1093
  /**
989
1094
  * List sessions for an agent.
990
1095
  */
991
- open func listSessions(agentId: String)throws -> String {
992
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
993
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_sessions(self.uniffiClonePointer(),
1096
+ open func listSessions(agentId: String)throws -> String {
1097
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1098
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_sessions(
1099
+ self.uniffiCloneHandle(),
994
1100
  FfiConverterString.lower(agentId),$0
995
1101
  )
996
1102
  })
@@ -999,9 +1105,10 @@ open func listSessions(agentId: String)throws -> String {
999
1105
  /**
1000
1106
  * List all cron skills.
1001
1107
  */
1002
- open func listSkills()throws -> String {
1003
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1004
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_skills(self.uniffiClonePointer(),$0
1108
+ open func listSkills()throws -> String {
1109
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1110
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_skills(
1111
+ self.uniffiCloneHandle(),$0
1005
1112
  )
1006
1113
  })
1007
1114
  }
@@ -1009,9 +1116,10 @@ open func listSkills()throws -> String {
1009
1116
  /**
1010
1117
  * List all tool permissions as JSON array.
1011
1118
  */
1012
- open func listToolPermissions()throws -> String {
1013
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1014
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_tool_permissions(self.uniffiClonePointer(),$0
1119
+ open func listToolPermissions()throws -> String {
1120
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1121
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_tool_permissions(
1122
+ self.uniffiCloneHandle(),$0
1015
1123
  )
1016
1124
  })
1017
1125
  }
@@ -1019,9 +1127,10 @@ open func listToolPermissions()throws -> String {
1019
1127
  /**
1020
1128
  * Load session message history.
1021
1129
  */
1022
- open func loadSession(sessionKey: String)throws -> String {
1023
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1024
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_session(self.uniffiClonePointer(),
1130
+ open func loadSession(sessionKey: String)throws -> String {
1131
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1132
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_session(
1133
+ self.uniffiCloneHandle(),
1025
1134
  FfiConverterString.lower(sessionKey),$0
1026
1135
  )
1027
1136
  })
@@ -1030,16 +1139,18 @@ open func loadSession(sessionKey: String)throws -> String {
1030
1139
  /**
1031
1140
  * Load surfaced messages from background/cron jobs.
1032
1141
  */
1033
- open func loadSurfacedMessages(limit: Int64)throws -> String {
1034
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1035
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_surfaced_messages(self.uniffiClonePointer(),
1142
+ open func loadSurfacedMessages(limit: Int64)throws -> String {
1143
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1144
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_surfaced_messages(
1145
+ self.uniffiCloneHandle(),
1036
1146
  FfiConverterInt64.lower(limit),$0
1037
1147
  )
1038
1148
  })
1039
1149
  }
1040
1150
 
1041
- open func persistConfig()throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1042
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_persist_config(self.uniffiClonePointer(),$0
1151
+ open func persistConfig()throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1152
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_persist_config(
1153
+ self.uniffiCloneHandle(),$0
1043
1154
  )
1044
1155
  }
1045
1156
  }
@@ -1047,9 +1158,10 @@ open func persistConfig()throws {try rustCallWithError(FfiConverterTypeNativeAg
1047
1158
  /**
1048
1159
  * Refresh an OAuth token.
1049
1160
  */
1050
- open func refreshToken(provider: String)throws -> AuthTokenResult {
1051
- return try FfiConverterTypeAuthTokenResult.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1052
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_refresh_token(self.uniffiClonePointer(),
1161
+ open func refreshToken(provider: String)throws -> AuthTokenResult {
1162
+ return try FfiConverterTypeAuthTokenResult_lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1163
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_refresh_token(
1164
+ self.uniffiCloneHandle(),
1053
1165
  FfiConverterString.lower(provider),$0
1054
1166
  )
1055
1167
  })
@@ -1058,8 +1170,9 @@ open func refreshToken(provider: String)throws -> AuthTokenResult {
1058
1170
  /**
1059
1171
  * Remove a cron job.
1060
1172
  */
1061
- open func removeCronJob(id: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1062
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_cron_job(self.uniffiClonePointer(),
1173
+ open func removeCronJob(id: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1174
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_cron_job(
1175
+ self.uniffiCloneHandle(),
1063
1176
  FfiConverterString.lower(id),$0
1064
1177
  )
1065
1178
  }
@@ -1068,8 +1181,9 @@ open func removeCronJob(id: String)throws {try rustCallWithError(FfiConverterTy
1068
1181
  /**
1069
1182
  * Remove a cron skill.
1070
1183
  */
1071
- open func removeSkill(id: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1072
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_skill(self.uniffiClonePointer(),
1184
+ open func removeSkill(id: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1185
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_skill(
1186
+ self.uniffiCloneHandle(),
1073
1187
  FfiConverterString.lower(id),$0
1074
1188
  )
1075
1189
  }
@@ -1078,8 +1192,9 @@ open func removeSkill(id: String)throws {try rustCallWithError(FfiConverterType
1078
1192
  /**
1079
1193
  * Delete all tool permissions (reset to defaults on next seed).
1080
1194
  */
1081
- open func resetToolPermissions()throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1082
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_reset_tool_permissions(self.uniffiClonePointer(),$0
1195
+ open func resetToolPermissions()throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1196
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_reset_tool_permissions(
1197
+ self.uniffiCloneHandle(),$0
1083
1198
  )
1084
1199
  }
1085
1200
  }
@@ -1087,8 +1202,9 @@ open func resetToolPermissions()throws {try rustCallWithError(FfiConverterTypeN
1087
1202
  /**
1088
1203
  * Respond to a tool approval request.
1089
1204
  */
1090
- open func respondToApproval(toolCallId: String, approved: Bool, reason: String?)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1091
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_approval(self.uniffiClonePointer(),
1205
+ open func respondToApproval(toolCallId: String, approved: Bool, reason: String?)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1206
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_approval(
1207
+ self.uniffiCloneHandle(),
1092
1208
  FfiConverterString.lower(toolCallId),
1093
1209
  FfiConverterBool.lower(approved),
1094
1210
  FfiConverterOptionString.lower(reason),$0
@@ -1099,8 +1215,9 @@ open func respondToApproval(toolCallId: String, approved: Bool, reason: String?)
1099
1215
  /**
1100
1216
  * Respond to a cron approval request.
1101
1217
  */
1102
- open func respondToCronApproval(requestId: String, approved: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1103
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_cron_approval(self.uniffiClonePointer(),
1218
+ open func respondToCronApproval(requestId: String, approved: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1219
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_cron_approval(
1220
+ self.uniffiCloneHandle(),
1104
1221
  FfiConverterString.lower(requestId),
1105
1222
  FfiConverterBool.lower(approved),$0
1106
1223
  )
@@ -1110,8 +1227,9 @@ open func respondToCronApproval(requestId: String, approved: Bool)throws {try r
1110
1227
  /**
1111
1228
  * Respond to a pending MCP tool call.
1112
1229
  */
1113
- open func respondToMcpTool(toolCallId: String, resultJson: String, isError: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1114
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_mcp_tool(self.uniffiClonePointer(),
1230
+ open func respondToMcpTool(toolCallId: String, resultJson: String, isError: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1231
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_mcp_tool(
1232
+ self.uniffiCloneHandle(),
1115
1233
  FfiConverterString.lower(toolCallId),
1116
1234
  FfiConverterString.lower(resultJson),
1117
1235
  FfiConverterBool.lower(isError),$0
@@ -1122,9 +1240,10 @@ open func respondToMcpTool(toolCallId: String, resultJson: String, isError: Bool
1122
1240
  /**
1123
1241
  * Restart MCP server with new tools.
1124
1242
  */
1125
- open func restartMcp(toolsJson: String)throws -> UInt32 {
1126
- return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1127
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_restart_mcp(self.uniffiClonePointer(),
1243
+ open func restartMcp(toolsJson: String)throws -> UInt32 {
1244
+ return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1245
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_restart_mcp(
1246
+ self.uniffiCloneHandle(),
1128
1247
  FfiConverterString.lower(toolsJson),$0
1129
1248
  )
1130
1249
  })
@@ -1135,9 +1254,10 @@ open func restartMcp(toolsJson: String)throws -> UInt32 {
1135
1254
  * Returns `was_interrupted: true` if the session had an in-progress turn
1136
1255
  * that was killed (e.g. app force-close). The caller can auto-resume.
1137
1256
  */
1138
- open func resumeSession(sessionKey: String, agentId: String, messagesJson: String?, provider: String?, model: String?)throws -> Bool {
1139
- return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1140
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_resume_session(self.uniffiClonePointer(),
1257
+ open func resumeSession(sessionKey: String, agentId: String, messagesJson: String?, provider: String?, model: String?)throws -> Bool {
1258
+ return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1259
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_resume_session(
1260
+ self.uniffiCloneHandle(),
1141
1261
  FfiConverterString.lower(sessionKey),
1142
1262
  FfiConverterString.lower(agentId),
1143
1263
  FfiConverterOptionString.lower(messagesJson),
@@ -1150,8 +1270,9 @@ open func resumeSession(sessionKey: String, agentId: String, messagesJson: Strin
1150
1270
  /**
1151
1271
  * Force-trigger a cron job.
1152
1272
  */
1153
- open func runCronJob(jobId: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1154
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_run_cron_job(self.uniffiClonePointer(),
1273
+ open func runCronJob(jobId: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1274
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_run_cron_job(
1275
+ self.uniffiCloneHandle(),
1155
1276
  FfiConverterString.lower(jobId),$0
1156
1277
  )
1157
1278
  }
@@ -1160,9 +1281,10 @@ open func runCronJob(jobId: String)throws {try rustCallWithError(FfiConverterTy
1160
1281
  /**
1161
1282
  * Seed tool permissions from defaults. INSERT OR IGNORE preserves user overrides.
1162
1283
  */
1163
- open func seedToolPermissions(defaultsJson: String)throws -> UInt32 {
1164
- return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1165
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_seed_tool_permissions(self.uniffiClonePointer(),
1284
+ open func seedToolPermissions(defaultsJson: String)throws -> UInt32 {
1285
+ return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1286
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_seed_tool_permissions(
1287
+ self.uniffiCloneHandle(),
1166
1288
  FfiConverterString.lower(defaultsJson),$0
1167
1289
  )
1168
1290
  })
@@ -1171,10 +1293,27 @@ open func seedToolPermissions(defaultsJson: String)throws -> UInt32 {
1171
1293
  /**
1172
1294
  * Send a message to the agent and start an agent loop turn.
1173
1295
  */
1174
- open func sendMessage(params: SendMessageParams)throws -> String {
1175
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1176
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_send_message(self.uniffiClonePointer(),
1177
- FfiConverterTypeSendMessageParams.lower(params),$0
1296
+ open func sendMessage(params: SendMessageParams)throws -> String {
1297
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1298
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_send_message(
1299
+ self.uniffiCloneHandle(),
1300
+ FfiConverterTypeSendMessageParams_lower(params),$0
1301
+ )
1302
+ })
1303
+ }
1304
+
1305
+ /**
1306
+ * Build a canonical `wire::AgentEvent` JSON envelope from the raw
1307
+ * event-type + payload pair the agent loop emits, stamping a fresh
1308
+ * `received_at`. Hosts call this to produce wire bytes for AMQP/STOMP.
1309
+ */
1310
+ open func serializeAgentEventJson(eventType: String, payloadJson: String, sessionKey: String?)throws -> String {
1311
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1312
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_serialize_agent_event_json(
1313
+ self.uniffiCloneHandle(),
1314
+ FfiConverterString.lower(eventType),
1315
+ FfiConverterString.lower(payloadJson),
1316
+ FfiConverterOptionString.lower(sessionKey),$0
1178
1317
  )
1179
1318
  })
1180
1319
  }
@@ -1182,8 +1321,9 @@ open func sendMessage(params: SendMessageParams)throws -> String {
1182
1321
  /**
1183
1322
  * Set an auth key for a provider.
1184
1323
  */
1185
- open func setAuthKey(key: String, provider: String, authType: String, refresh: String?, expiresAt: Int64?)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1186
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(self.uniffiClonePointer(),
1324
+ open func setAuthKey(key: String, provider: String, authType: String, refresh: String?, expiresAt: Int64?)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1325
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(
1326
+ self.uniffiCloneHandle(),
1187
1327
  FfiConverterString.lower(key),
1188
1328
  FfiConverterString.lower(provider),
1189
1329
  FfiConverterString.lower(authType),
@@ -1196,9 +1336,10 @@ open func setAuthKey(key: String, provider: String, authType: String, refresh: S
1196
1336
  /**
1197
1337
  * Set the event callback for receiving agent events.
1198
1338
  */
1199
- open func setEventCallback(callback: NativeEventCallback)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1200
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_event_callback(self.uniffiClonePointer(),
1201
- FfiConverterCallbackInterfaceNativeEventCallback.lower(callback),$0
1339
+ open func setEventCallback(callback: NativeEventCallback)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1340
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_event_callback(
1341
+ self.uniffiCloneHandle(),
1342
+ FfiConverterCallbackInterfaceNativeEventCallback_lower(callback),$0
1202
1343
  )
1203
1344
  }
1204
1345
  }
@@ -1207,9 +1348,10 @@ open func setEventCallback(callback: NativeEventCallback)throws {try rustCallWi
1207
1348
  * Set the optional governance provider (taint, audit, loop-guard, cost tracking).
1208
1349
  * Typically called by capacitor-agent-os when it auto-registers at init time.
1209
1350
  */
1210
- open func setGovernanceProvider(provider: GovernanceProvider)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1211
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_governance_provider(self.uniffiClonePointer(),
1212
- FfiConverterCallbackInterfaceGovernanceProvider.lower(provider),$0
1351
+ open func setGovernanceProvider(provider: GovernanceProvider)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1352
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_governance_provider(
1353
+ self.uniffiCloneHandle(),
1354
+ FfiConverterCallbackInterfaceGovernanceProvider_lower(provider),$0
1213
1355
  )
1214
1356
  }
1215
1357
  }
@@ -1217,23 +1359,26 @@ open func setGovernanceProvider(provider: GovernanceProvider)throws {try rustCa
1217
1359
  /**
1218
1360
  * Set heartbeat config.
1219
1361
  */
1220
- open func setHeartbeatConfig(configJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1221
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_heartbeat_config(self.uniffiClonePointer(),
1362
+ open func setHeartbeatConfig(configJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1363
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_heartbeat_config(
1364
+ self.uniffiCloneHandle(),
1222
1365
  FfiConverterString.lower(configJson),$0
1223
1366
  )
1224
1367
  }
1225
1368
  }
1226
1369
 
1227
- open func setMemoryProvider(provider: MemoryProvider)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1228
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_memory_provider(self.uniffiClonePointer(),
1229
- FfiConverterCallbackInterfaceMemoryProvider.lower(provider),$0
1370
+ open func setMemoryProvider(provider: MemoryProvider)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1371
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_memory_provider(
1372
+ self.uniffiCloneHandle(),
1373
+ FfiConverterCallbackInterfaceMemoryProvider_lower(provider),$0
1230
1374
  )
1231
1375
  }
1232
1376
  }
1233
1377
 
1234
- open func setNotifier(notifier: NativeNotifier)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1235
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_notifier(self.uniffiClonePointer(),
1236
- FfiConverterCallbackInterfaceNativeNotifier.lower(notifier),$0
1378
+ open func setNotifier(notifier: NativeNotifier)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1379
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_notifier(
1380
+ self.uniffiCloneHandle(),
1381
+ FfiConverterCallbackInterfaceNativeNotifier_lower(notifier),$0
1237
1382
  )
1238
1383
  }
1239
1384
  }
@@ -1241,8 +1386,9 @@ open func setNotifier(notifier: NativeNotifier)throws {try rustCallWithError(Ff
1241
1386
  /**
1242
1387
  * Set scheduler config.
1243
1388
  */
1244
- open func setSchedulerConfig(configJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1245
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_scheduler_config(self.uniffiClonePointer(),
1389
+ open func setSchedulerConfig(configJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1390
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_scheduler_config(
1391
+ self.uniffiCloneHandle(),
1246
1392
  FfiConverterString.lower(configJson),$0
1247
1393
  )
1248
1394
  }
@@ -1251,8 +1397,9 @@ open func setSchedulerConfig(configJson: String)throws {try rustCallWithError(F
1251
1397
  /**
1252
1398
  * Set a single tool's permission (upsert).
1253
1399
  */
1254
- open func setToolPermission(toolName: String, permission: String, enabled: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1255
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_tool_permission(self.uniffiClonePointer(),
1400
+ open func setToolPermission(toolName: String, permission: String, enabled: Bool)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1401
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_tool_permission(
1402
+ self.uniffiCloneHandle(),
1256
1403
  FfiConverterString.lower(toolName),
1257
1404
  FfiConverterString.lower(permission),
1258
1405
  FfiConverterBool.lower(enabled),$0
@@ -1263,9 +1410,10 @@ open func setToolPermission(toolName: String, permission: String, enabled: Bool)
1263
1410
  /**
1264
1411
  * Start MCP server with given tools.
1265
1412
  */
1266
- open func startMcp(toolsJson: String)throws -> UInt32 {
1267
- return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1268
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_mcp(self.uniffiClonePointer(),
1413
+ open func startMcp(toolsJson: String)throws -> UInt32 {
1414
+ return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1415
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_mcp(
1416
+ self.uniffiCloneHandle(),
1269
1417
  FfiConverterString.lower(toolsJson),$0
1270
1418
  )
1271
1419
  })
@@ -1274,9 +1422,10 @@ open func startMcp(toolsJson: String)throws -> UInt32 {
1274
1422
  /**
1275
1423
  * Start a skill session.
1276
1424
  */
1277
- open func startSkill(skillId: String, configJson: String, provider: String?)throws -> String {
1278
- return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1279
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_skill(self.uniffiClonePointer(),
1425
+ open func startSkill(skillId: String, configJson: String, provider: String?)throws -> String {
1426
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1427
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_skill(
1428
+ self.uniffiCloneHandle(),
1280
1429
  FfiConverterString.lower(skillId),
1281
1430
  FfiConverterString.lower(configJson),
1282
1431
  FfiConverterOptionString.lower(provider),$0
@@ -1287,8 +1436,9 @@ open func startSkill(skillId: String, configJson: String, provider: String?)thro
1287
1436
  /**
1288
1437
  * Steer the running agent with additional context.
1289
1438
  */
1290
- open func steer(text: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1291
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_steer(self.uniffiClonePointer(),
1439
+ open func steer(text: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1440
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_steer(
1441
+ self.uniffiCloneHandle(),
1292
1442
  FfiConverterString.lower(text),$0
1293
1443
  )
1294
1444
  }
@@ -1297,8 +1447,9 @@ open func steer(text: String)throws {try rustCallWithError(FfiConverterTypeNati
1297
1447
  /**
1298
1448
  * Update a cron job.
1299
1449
  */
1300
- open func updateCronJob(id: String, patchJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1301
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_cron_job(self.uniffiClonePointer(),
1450
+ open func updateCronJob(id: String, patchJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1451
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_cron_job(
1452
+ self.uniffiCloneHandle(),
1302
1453
  FfiConverterString.lower(id),
1303
1454
  FfiConverterString.lower(patchJson),$0
1304
1455
  )
@@ -1308,8 +1459,9 @@ open func updateCronJob(id: String, patchJson: String)throws {try rustCallWithE
1308
1459
  /**
1309
1460
  * Update a cron skill.
1310
1461
  */
1311
- open func updateSkill(id: String, patchJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
1312
- uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_skill(self.uniffiClonePointer(),
1462
+ open func updateSkill(id: String, patchJson: String)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
1463
+ uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_skill(
1464
+ self.uniffiCloneHandle(),
1313
1465
  FfiConverterString.lower(id),
1314
1466
  FfiConverterString.lower(patchJson),$0
1315
1467
  )
@@ -1317,64 +1469,57 @@ open func updateSkill(id: String, patchJson: String)throws {try rustCallWithErr
1317
1469
  }
1318
1470
 
1319
1471
 
1472
+
1320
1473
  }
1321
1474
 
1475
+
1322
1476
  #if swift(>=5.8)
1323
1477
  @_documentation(visibility: private)
1324
1478
  #endif
1325
1479
  public struct FfiConverterTypeNativeAgentHandle: FfiConverter {
1326
-
1327
- typealias FfiType = UnsafeMutableRawPointer
1480
+ typealias FfiType = UInt64
1328
1481
  typealias SwiftType = NativeAgentHandle
1329
1482
 
1330
- public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> NativeAgentHandle {
1331
- return NativeAgentHandle(unsafeFromRawPointer: pointer)
1483
+ public static func lift(_ handle: UInt64) throws -> NativeAgentHandle {
1484
+ return NativeAgentHandle(unsafeFromHandle: handle)
1332
1485
  }
1333
1486
 
1334
- public static func lower(_ value: NativeAgentHandle) -> UnsafeMutableRawPointer {
1335
- return value.uniffiClonePointer()
1487
+ public static func lower(_ value: NativeAgentHandle) -> UInt64 {
1488
+ return value.uniffiCloneHandle()
1336
1489
  }
1337
1490
 
1338
1491
  public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeAgentHandle {
1339
- let v: UInt64 = try readInt(&buf)
1340
- // The Rust code won't compile if a pointer won't fit in a UInt64.
1341
- // We have to go via `UInt` because that's the thing that's the size of a pointer.
1342
- let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
1343
- if (ptr == nil) {
1344
- throw UniffiInternalError.unexpectedNullPointer
1345
- }
1346
- return try lift(ptr!)
1492
+ let handle: UInt64 = try readInt(&buf)
1493
+ return try lift(handle)
1347
1494
  }
1348
1495
 
1349
1496
  public static func write(_ value: NativeAgentHandle, into buf: inout [UInt8]) {
1350
- // This fiddling is because `Int` is the thing that's the same size as a pointer.
1351
- // The Rust code won't compile if a pointer won't fit in a `UInt64`.
1352
- writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
1497
+ writeInt(&buf, lower(value))
1353
1498
  }
1354
1499
  }
1355
1500
 
1356
1501
 
1357
-
1358
-
1359
1502
  #if swift(>=5.8)
1360
1503
  @_documentation(visibility: private)
1361
1504
  #endif
1362
- public func FfiConverterTypeNativeAgentHandle_lift(_ pointer: UnsafeMutableRawPointer) throws -> NativeAgentHandle {
1363
- return try FfiConverterTypeNativeAgentHandle.lift(pointer)
1505
+ public func FfiConverterTypeNativeAgentHandle_lift(_ handle: UInt64) throws -> NativeAgentHandle {
1506
+ return try FfiConverterTypeNativeAgentHandle.lift(handle)
1364
1507
  }
1365
1508
 
1366
1509
  #if swift(>=5.8)
1367
1510
  @_documentation(visibility: private)
1368
1511
  #endif
1369
- public func FfiConverterTypeNativeAgentHandle_lower(_ value: NativeAgentHandle) -> UnsafeMutableRawPointer {
1512
+ public func FfiConverterTypeNativeAgentHandle_lower(_ value: NativeAgentHandle) -> UInt64 {
1370
1513
  return FfiConverterTypeNativeAgentHandle.lower(value)
1371
1514
  }
1372
1515
 
1373
1516
 
1517
+
1518
+
1374
1519
  /**
1375
1520
  * Auth status result.
1376
1521
  */
1377
- public struct AuthStatusResult {
1522
+ public struct AuthStatusResult: Equatable, Hashable {
1378
1523
  public var hasKey: Bool
1379
1524
  public var masked: String
1380
1525
  public var provider: String
@@ -1386,31 +1531,15 @@ public struct AuthStatusResult {
1386
1531
  self.masked = masked
1387
1532
  self.provider = provider
1388
1533
  }
1389
- }
1390
-
1391
-
1392
1534
 
1393
- extension AuthStatusResult: Equatable, Hashable {
1394
- public static func ==(lhs: AuthStatusResult, rhs: AuthStatusResult) -> Bool {
1395
- if lhs.hasKey != rhs.hasKey {
1396
- return false
1397
- }
1398
- if lhs.masked != rhs.masked {
1399
- return false
1400
- }
1401
- if lhs.provider != rhs.provider {
1402
- return false
1403
- }
1404
- return true
1405
- }
1535
+
1406
1536
 
1407
- public func hash(into hasher: inout Hasher) {
1408
- hasher.combine(hasKey)
1409
- hasher.combine(masked)
1410
- hasher.combine(provider)
1411
- }
1537
+
1412
1538
  }
1413
1539
 
1540
+ #if compiler(>=6)
1541
+ extension AuthStatusResult: Sendable {}
1542
+ #endif
1414
1543
 
1415
1544
  #if swift(>=5.8)
1416
1545
  @_documentation(visibility: private)
@@ -1451,7 +1580,7 @@ public func FfiConverterTypeAuthStatusResult_lower(_ value: AuthStatusResult) ->
1451
1580
  /**
1452
1581
  * Auth token result.
1453
1582
  */
1454
- public struct AuthTokenResult {
1583
+ public struct AuthTokenResult: Equatable, Hashable {
1455
1584
  public var apiKey: String?
1456
1585
  public var isOauth: Bool
1457
1586
 
@@ -1461,27 +1590,15 @@ public struct AuthTokenResult {
1461
1590
  self.apiKey = apiKey
1462
1591
  self.isOauth = isOauth
1463
1592
  }
1464
- }
1465
-
1466
1593
 
1594
+
1467
1595
 
1468
- extension AuthTokenResult: Equatable, Hashable {
1469
- public static func ==(lhs: AuthTokenResult, rhs: AuthTokenResult) -> Bool {
1470
- if lhs.apiKey != rhs.apiKey {
1471
- return false
1472
- }
1473
- if lhs.isOauth != rhs.isOauth {
1474
- return false
1475
- }
1476
- return true
1477
- }
1478
-
1479
- public func hash(into hasher: inout Hasher) {
1480
- hasher.combine(apiKey)
1481
- hasher.combine(isOauth)
1482
- }
1596
+
1483
1597
  }
1484
1598
 
1599
+ #if compiler(>=6)
1600
+ extension AuthTokenResult: Sendable {}
1601
+ #endif
1485
1602
 
1486
1603
  #if swift(>=5.8)
1487
1604
  @_documentation(visibility: private)
@@ -1520,7 +1637,7 @@ public func FfiConverterTypeAuthTokenResult_lower(_ value: AuthTokenResult) -> R
1520
1637
  /**
1521
1638
  * Configuration for initializing the native agent handle.
1522
1639
  */
1523
- public struct InitConfig {
1640
+ public struct InitConfig: Equatable, Hashable {
1524
1641
  /**
1525
1642
  * Path to the SQLite database.
1526
1643
  */
@@ -1578,39 +1695,15 @@ public struct InitConfig {
1578
1695
  self.defaultProvider = defaultProvider
1579
1696
  self.defaultModel = defaultModel
1580
1697
  }
1581
- }
1582
-
1583
1698
 
1699
+
1584
1700
 
1585
- extension InitConfig: Equatable, Hashable {
1586
- public static func ==(lhs: InitConfig, rhs: InitConfig) -> Bool {
1587
- if lhs.dbPath != rhs.dbPath {
1588
- return false
1589
- }
1590
- if lhs.workspacePath != rhs.workspacePath {
1591
- return false
1592
- }
1593
- if lhs.authProfilesPath != rhs.authProfilesPath {
1594
- return false
1595
- }
1596
- if lhs.defaultProvider != rhs.defaultProvider {
1597
- return false
1598
- }
1599
- if lhs.defaultModel != rhs.defaultModel {
1600
- return false
1601
- }
1602
- return true
1603
- }
1604
-
1605
- public func hash(into hasher: inout Hasher) {
1606
- hasher.combine(dbPath)
1607
- hasher.combine(workspacePath)
1608
- hasher.combine(authProfilesPath)
1609
- hasher.combine(defaultProvider)
1610
- hasher.combine(defaultModel)
1611
- }
1701
+
1612
1702
  }
1613
1703
 
1704
+ #if compiler(>=6)
1705
+ extension InitConfig: Sendable {}
1706
+ #endif
1614
1707
 
1615
1708
  #if swift(>=5.8)
1616
1709
  @_documentation(visibility: private)
@@ -1652,10 +1745,93 @@ public func FfiConverterTypeInitConfig_lower(_ value: InitConfig) -> RustBuffer
1652
1745
  }
1653
1746
 
1654
1747
 
1748
+ /**
1749
+ * One entry in the catalog. Field names mirror the JSON's camelCase
1750
+ * shape. Hosts use this to populate their permissions UI and to seed
1751
+ * the AgentStore's tool_permissions table on first run.
1752
+ */
1753
+ public struct NativeToolDescriptor: Equatable, Hashable {
1754
+ public var name: String
1755
+ public var description: String
1756
+ public var source: String
1757
+ public var groupId: String
1758
+ public var groupLabel: String
1759
+ public var category: String
1760
+ public var defaultPermission: String
1761
+ public var defaultEnabled: Bool
1762
+
1763
+ // Default memberwise initializers are never public by default, so we
1764
+ // declare one manually.
1765
+ public init(name: String, description: String, source: String, groupId: String, groupLabel: String, category: String, defaultPermission: String, defaultEnabled: Bool) {
1766
+ self.name = name
1767
+ self.description = description
1768
+ self.source = source
1769
+ self.groupId = groupId
1770
+ self.groupLabel = groupLabel
1771
+ self.category = category
1772
+ self.defaultPermission = defaultPermission
1773
+ self.defaultEnabled = defaultEnabled
1774
+ }
1775
+
1776
+
1777
+
1778
+
1779
+ }
1780
+
1781
+ #if compiler(>=6)
1782
+ extension NativeToolDescriptor: Sendable {}
1783
+ #endif
1784
+
1785
+ #if swift(>=5.8)
1786
+ @_documentation(visibility: private)
1787
+ #endif
1788
+ public struct FfiConverterTypeNativeToolDescriptor: FfiConverterRustBuffer {
1789
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeToolDescriptor {
1790
+ return
1791
+ try NativeToolDescriptor(
1792
+ name: FfiConverterString.read(from: &buf),
1793
+ description: FfiConverterString.read(from: &buf),
1794
+ source: FfiConverterString.read(from: &buf),
1795
+ groupId: FfiConverterString.read(from: &buf),
1796
+ groupLabel: FfiConverterString.read(from: &buf),
1797
+ category: FfiConverterString.read(from: &buf),
1798
+ defaultPermission: FfiConverterString.read(from: &buf),
1799
+ defaultEnabled: FfiConverterBool.read(from: &buf)
1800
+ )
1801
+ }
1802
+
1803
+ public static func write(_ value: NativeToolDescriptor, into buf: inout [UInt8]) {
1804
+ FfiConverterString.write(value.name, into: &buf)
1805
+ FfiConverterString.write(value.description, into: &buf)
1806
+ FfiConverterString.write(value.source, into: &buf)
1807
+ FfiConverterString.write(value.groupId, into: &buf)
1808
+ FfiConverterString.write(value.groupLabel, into: &buf)
1809
+ FfiConverterString.write(value.category, into: &buf)
1810
+ FfiConverterString.write(value.defaultPermission, into: &buf)
1811
+ FfiConverterBool.write(value.defaultEnabled, into: &buf)
1812
+ }
1813
+ }
1814
+
1815
+
1816
+ #if swift(>=5.8)
1817
+ @_documentation(visibility: private)
1818
+ #endif
1819
+ public func FfiConverterTypeNativeToolDescriptor_lift(_ buf: RustBuffer) throws -> NativeToolDescriptor {
1820
+ return try FfiConverterTypeNativeToolDescriptor.lift(buf)
1821
+ }
1822
+
1823
+ #if swift(>=5.8)
1824
+ @_documentation(visibility: private)
1825
+ #endif
1826
+ public func FfiConverterTypeNativeToolDescriptor_lower(_ value: NativeToolDescriptor) -> RustBuffer {
1827
+ return FfiConverterTypeNativeToolDescriptor.lower(value)
1828
+ }
1829
+
1830
+
1655
1831
  /**
1656
1832
  * Buffered event emitted while no foreground callback is attached.
1657
1833
  */
1658
- public struct PendingEvent {
1834
+ public struct PendingEvent: Equatable, Hashable {
1659
1835
  public var id: Int64
1660
1836
  public var eventType: String
1661
1837
  public var payloadJson: String
@@ -1669,35 +1845,15 @@ public struct PendingEvent {
1669
1845
  self.payloadJson = payloadJson
1670
1846
  self.createdAt = createdAt
1671
1847
  }
1672
- }
1673
1848
 
1849
+
1674
1850
 
1675
-
1676
- extension PendingEvent: Equatable, Hashable {
1677
- public static func ==(lhs: PendingEvent, rhs: PendingEvent) -> Bool {
1678
- if lhs.id != rhs.id {
1679
- return false
1680
- }
1681
- if lhs.eventType != rhs.eventType {
1682
- return false
1683
- }
1684
- if lhs.payloadJson != rhs.payloadJson {
1685
- return false
1686
- }
1687
- if lhs.createdAt != rhs.createdAt {
1688
- return false
1689
- }
1690
- return true
1691
- }
1692
-
1693
- public func hash(into hasher: inout Hasher) {
1694
- hasher.combine(id)
1695
- hasher.combine(eventType)
1696
- hasher.combine(payloadJson)
1697
- hasher.combine(createdAt)
1698
- }
1851
+
1699
1852
  }
1700
1853
 
1854
+ #if compiler(>=6)
1855
+ extension PendingEvent: Sendable {}
1856
+ #endif
1701
1857
 
1702
1858
  #if swift(>=5.8)
1703
1859
  @_documentation(visibility: private)
@@ -1740,7 +1896,7 @@ public func FfiConverterTypePendingEvent_lower(_ value: PendingEvent) -> RustBuf
1740
1896
  /**
1741
1897
  * Parameters for sending a message.
1742
1898
  */
1743
- public struct SendMessageParams {
1899
+ public struct SendMessageParams: Equatable, Hashable {
1744
1900
  public var prompt: String
1745
1901
  public var sessionKey: String
1746
1902
  public var model: String?
@@ -1748,9 +1904,11 @@ public struct SendMessageParams {
1748
1904
  public var systemPrompt: String
1749
1905
  public var maxTurns: UInt32?
1750
1906
  /**
1751
- * JSON-encoded list of allowed tool names. Empty = all tools.
1907
+ * Optional skill-mode whitelist of allowed tool names (JSON-encoded array).
1908
+ * `None` or empty = no skill restriction. The FFI also applies its own
1909
+ * per-turn permission filter from the AgentStore on top of this list.
1752
1910
  */
1753
- public var allowedToolsJson: String?
1911
+ public var skillAllowedToolsJson: String?
1754
1912
  /**
1755
1913
  * JSON-encoded prior conversation messages for multi-turn sessions.
1756
1914
  */
@@ -1760,8 +1918,10 @@ public struct SendMessageParams {
1760
1918
  // declare one manually.
1761
1919
  public init(prompt: String, sessionKey: String, model: String?, provider: String?, systemPrompt: String, maxTurns: UInt32?,
1762
1920
  /**
1763
- * JSON-encoded list of allowed tool names. Empty = all tools.
1764
- */allowedToolsJson: String?,
1921
+ * Optional skill-mode whitelist of allowed tool names (JSON-encoded array).
1922
+ * `None` or empty = no skill restriction. The FFI also applies its own
1923
+ * per-turn permission filter from the AgentStore on top of this list.
1924
+ */skillAllowedToolsJson: String?,
1765
1925
  /**
1766
1926
  * JSON-encoded prior conversation messages for multi-turn sessions.
1767
1927
  */priorMessagesJson: String?) {
@@ -1771,54 +1931,18 @@ public struct SendMessageParams {
1771
1931
  self.provider = provider
1772
1932
  self.systemPrompt = systemPrompt
1773
1933
  self.maxTurns = maxTurns
1774
- self.allowedToolsJson = allowedToolsJson
1934
+ self.skillAllowedToolsJson = skillAllowedToolsJson
1775
1935
  self.priorMessagesJson = priorMessagesJson
1776
1936
  }
1777
- }
1778
-
1779
-
1780
1937
 
1781
- extension SendMessageParams: Equatable, Hashable {
1782
- public static func ==(lhs: SendMessageParams, rhs: SendMessageParams) -> Bool {
1783
- if lhs.prompt != rhs.prompt {
1784
- return false
1785
- }
1786
- if lhs.sessionKey != rhs.sessionKey {
1787
- return false
1788
- }
1789
- if lhs.model != rhs.model {
1790
- return false
1791
- }
1792
- if lhs.provider != rhs.provider {
1793
- return false
1794
- }
1795
- if lhs.systemPrompt != rhs.systemPrompt {
1796
- return false
1797
- }
1798
- if lhs.maxTurns != rhs.maxTurns {
1799
- return false
1800
- }
1801
- if lhs.allowedToolsJson != rhs.allowedToolsJson {
1802
- return false
1803
- }
1804
- if lhs.priorMessagesJson != rhs.priorMessagesJson {
1805
- return false
1806
- }
1807
- return true
1808
- }
1938
+
1809
1939
 
1810
- public func hash(into hasher: inout Hasher) {
1811
- hasher.combine(prompt)
1812
- hasher.combine(sessionKey)
1813
- hasher.combine(model)
1814
- hasher.combine(provider)
1815
- hasher.combine(systemPrompt)
1816
- hasher.combine(maxTurns)
1817
- hasher.combine(allowedToolsJson)
1818
- hasher.combine(priorMessagesJson)
1819
- }
1940
+
1820
1941
  }
1821
1942
 
1943
+ #if compiler(>=6)
1944
+ extension SendMessageParams: Sendable {}
1945
+ #endif
1822
1946
 
1823
1947
  #if swift(>=5.8)
1824
1948
  @_documentation(visibility: private)
@@ -1833,7 +1957,7 @@ public struct FfiConverterTypeSendMessageParams: FfiConverterRustBuffer {
1833
1957
  provider: FfiConverterOptionString.read(from: &buf),
1834
1958
  systemPrompt: FfiConverterString.read(from: &buf),
1835
1959
  maxTurns: FfiConverterOptionUInt32.read(from: &buf),
1836
- allowedToolsJson: FfiConverterOptionString.read(from: &buf),
1960
+ skillAllowedToolsJson: FfiConverterOptionString.read(from: &buf),
1837
1961
  priorMessagesJson: FfiConverterOptionString.read(from: &buf)
1838
1962
  )
1839
1963
  }
@@ -1845,7 +1969,7 @@ public struct FfiConverterTypeSendMessageParams: FfiConverterRustBuffer {
1845
1969
  FfiConverterOptionString.write(value.provider, into: &buf)
1846
1970
  FfiConverterString.write(value.systemPrompt, into: &buf)
1847
1971
  FfiConverterOptionUInt32.write(value.maxTurns, into: &buf)
1848
- FfiConverterOptionString.write(value.allowedToolsJson, into: &buf)
1972
+ FfiConverterOptionString.write(value.skillAllowedToolsJson, into: &buf)
1849
1973
  FfiConverterOptionString.write(value.priorMessagesJson, into: &buf)
1850
1974
  }
1851
1975
  }
@@ -1869,7 +1993,7 @@ public func FfiConverterTypeSendMessageParams_lower(_ value: SendMessageParams)
1869
1993
  /**
1870
1994
  * Token usage from an agent turn.
1871
1995
  */
1872
- public struct TokenUsage {
1996
+ public struct TokenUsage: Equatable, Hashable {
1873
1997
  public var inputTokens: UInt32
1874
1998
  public var outputTokens: UInt32
1875
1999
  public var totalTokens: UInt32
@@ -1881,31 +2005,15 @@ public struct TokenUsage {
1881
2005
  self.outputTokens = outputTokens
1882
2006
  self.totalTokens = totalTokens
1883
2007
  }
1884
- }
1885
-
1886
-
1887
2008
 
1888
- extension TokenUsage: Equatable, Hashable {
1889
- public static func ==(lhs: TokenUsage, rhs: TokenUsage) -> Bool {
1890
- if lhs.inputTokens != rhs.inputTokens {
1891
- return false
1892
- }
1893
- if lhs.outputTokens != rhs.outputTokens {
1894
- return false
1895
- }
1896
- if lhs.totalTokens != rhs.totalTokens {
1897
- return false
1898
- }
1899
- return true
1900
- }
2009
+
1901
2010
 
1902
- public func hash(into hasher: inout Hasher) {
1903
- hasher.combine(inputTokens)
1904
- hasher.combine(outputTokens)
1905
- hasher.combine(totalTokens)
1906
- }
2011
+
1907
2012
  }
1908
2013
 
2014
+ #if compiler(>=6)
2015
+ extension TokenUsage: Sendable {}
2016
+ #endif
1909
2017
 
1910
2018
  #if swift(>=5.8)
1911
2019
  @_documentation(visibility: private)
@@ -1946,7 +2054,7 @@ public func FfiConverterTypeTokenUsage_lower(_ value: TokenUsage) -> RustBuffer
1946
2054
  /**
1947
2055
  * Top-level error type exposed via UniFFI.
1948
2056
  */
1949
- public enum NativeAgentError {
2057
+ public enum NativeAgentError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
1950
2058
 
1951
2059
 
1952
2060
 
@@ -1963,8 +2071,21 @@ public enum NativeAgentError {
1963
2071
  case Io(msg: String
1964
2072
  )
1965
2073
  case Cancelled
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+
2080
+ public var errorDescription: String? {
2081
+ String(reflecting: self)
2082
+ }
2083
+
1966
2084
  }
1967
2085
 
2086
+ #if compiler(>=6)
2087
+ extension NativeAgentError: Sendable {}
2088
+ #endif
1968
2089
 
1969
2090
  #if swift(>=5.8)
1970
2091
  @_documentation(visibility: private)
@@ -2048,12 +2169,193 @@ public struct FfiConverterTypeNativeAgentError: FfiConverterRustBuffer {
2048
2169
  }
2049
2170
 
2050
2171
 
2051
- extension NativeAgentError: Equatable, Hashable {}
2172
+ #if swift(>=5.8)
2173
+ @_documentation(visibility: private)
2174
+ #endif
2175
+ public func FfiConverterTypeNativeAgentError_lift(_ buf: RustBuffer) throws -> NativeAgentError {
2176
+ return try FfiConverterTypeNativeAgentError.lift(buf)
2177
+ }
2052
2178
 
2053
- extension NativeAgentError: Foundation.LocalizedError {
2054
- public var errorDescription: String? {
2055
- String(reflecting: self)
2179
+ #if swift(>=5.8)
2180
+ @_documentation(visibility: private)
2181
+ #endif
2182
+ public func FfiConverterTypeNativeAgentError_lower(_ value: NativeAgentError) -> RustBuffer {
2183
+ return FfiConverterTypeNativeAgentError.lower(value)
2184
+ }
2185
+
2186
+
2187
+
2188
+
2189
+ /**
2190
+ * Callback interface implemented by hosts to store the auth-profiles
2191
+ * envelope. Methods cross the FFI as JSON strings.
2192
+ */
2193
+ public protocol AuthProfileStore: AnyObject, Sendable {
2194
+
2195
+ /**
2196
+ * Return the full auth-profiles JSON envelope. When the host has
2197
+ * nothing stored yet, return an empty default envelope:
2198
+ * `{"version":1,"profiles":{},"lastGood":{},"usageStats":{}}`.
2199
+ */
2200
+ func load() -> String
2201
+
2202
+ /**
2203
+ * Persist the full auth-profiles JSON envelope. The host is
2204
+ * responsible for atomicity + permissions (e.g. file mode 0600).
2205
+ *
2206
+ * Returns an error on failure so callers like `set_auth_key` can
2207
+ * surface the problem instead of silently losing the user's auth
2208
+ * update. Use `NativeAgentError::Auth { msg }` so the variant
2209
+ * matches the rest of `auth.rs`'s error vocabulary; UniFFI bindgens
2210
+ * accept this type because `AgentStore`'s methods already do.
2211
+ */
2212
+ func save(profilesJson: String) throws
2213
+
2214
+ }
2215
+
2216
+
2217
+ // Put the implementation in a struct so we don't pollute the top-level namespace
2218
+ fileprivate struct UniffiCallbackInterfaceAuthProfileStore {
2219
+
2220
+ // Create the VTable using a series of closures.
2221
+ // Swift automatically converts these into C callback functions.
2222
+ //
2223
+ // Store the vtable directly.
2224
+ static let vtable: UniffiVTableCallbackInterfaceAuthProfileStore = UniffiVTableCallbackInterfaceAuthProfileStore(
2225
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
2226
+ do {
2227
+ try FfiConverterCallbackInterfaceAuthProfileStore.handleMap.remove(handle: uniffiHandle)
2228
+ } catch {
2229
+ print("Uniffi callback interface AuthProfileStore: handle missing in uniffiFree")
2230
+ }
2231
+ },
2232
+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
2233
+ do {
2234
+ return try FfiConverterCallbackInterfaceAuthProfileStore.handleMap.clone(handle: uniffiHandle)
2235
+ } catch {
2236
+ fatalError("Uniffi callback interface AuthProfileStore: handle missing in uniffiClone")
2237
+ }
2238
+ },
2239
+ load: { (
2240
+ uniffiHandle: UInt64,
2241
+ uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
2242
+ uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
2243
+ ) in
2244
+ let makeCall = {
2245
+ () throws -> String in
2246
+ guard let uniffiObj = try? FfiConverterCallbackInterfaceAuthProfileStore.handleMap.get(handle: uniffiHandle) else {
2247
+ throw UniffiInternalError.unexpectedStaleHandle
2248
+ }
2249
+ return uniffiObj.load(
2250
+ )
2251
+ }
2252
+
2253
+
2254
+ let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) }
2255
+ uniffiTraitInterfaceCall(
2256
+ callStatus: uniffiCallStatus,
2257
+ makeCall: makeCall,
2258
+ writeReturn: writeReturn
2259
+ )
2260
+ },
2261
+ save: { (
2262
+ uniffiHandle: UInt64,
2263
+ profilesJson: RustBuffer,
2264
+ uniffiOutReturn: UnsafeMutableRawPointer,
2265
+ uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
2266
+ ) in
2267
+ let makeCall = {
2268
+ () throws -> () in
2269
+ guard let uniffiObj = try? FfiConverterCallbackInterfaceAuthProfileStore.handleMap.get(handle: uniffiHandle) else {
2270
+ throw UniffiInternalError.unexpectedStaleHandle
2271
+ }
2272
+ return try uniffiObj.save(
2273
+ profilesJson: try FfiConverterString.lift(profilesJson)
2274
+ )
2275
+ }
2276
+
2277
+
2278
+ let writeReturn = { () }
2279
+ uniffiTraitInterfaceCallWithError(
2280
+ callStatus: uniffiCallStatus,
2281
+ makeCall: makeCall,
2282
+ writeReturn: writeReturn,
2283
+ lowerError: FfiConverterTypeNativeAgentError_lower
2284
+ )
2285
+ }
2286
+ )
2287
+
2288
+ // Rust stores this pointer for future callback invocations, so it must live
2289
+ // for the process lifetime (not just for the init function call).
2290
+ static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceAuthProfileStore> = {
2291
+ let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceAuthProfileStore>.allocate(capacity: 1)
2292
+ ptr.initialize(to: vtable)
2293
+ return UnsafePointer(ptr)
2294
+ }()
2295
+ }
2296
+
2297
+ private func uniffiCallbackInitAuthProfileStore() {
2298
+ uniffi_native_agent_ffi_fn_init_callback_vtable_authprofilestore(UniffiCallbackInterfaceAuthProfileStore.vtablePtr)
2299
+ }
2300
+
2301
+ // FfiConverter protocol for callback interfaces
2302
+ #if swift(>=5.8)
2303
+ @_documentation(visibility: private)
2304
+ #endif
2305
+ fileprivate struct FfiConverterCallbackInterfaceAuthProfileStore {
2306
+ fileprivate static let handleMap = UniffiHandleMap<AuthProfileStore>()
2307
+ }
2308
+
2309
+ #if swift(>=5.8)
2310
+ @_documentation(visibility: private)
2311
+ #endif
2312
+ extension FfiConverterCallbackInterfaceAuthProfileStore : FfiConverter {
2313
+ typealias SwiftType = AuthProfileStore
2314
+ typealias FfiType = UInt64
2315
+
2316
+ #if swift(>=5.8)
2317
+ @_documentation(visibility: private)
2318
+ #endif
2319
+ public static func lift(_ handle: UInt64) throws -> SwiftType {
2320
+ try handleMap.get(handle: handle)
2321
+ }
2322
+
2323
+ #if swift(>=5.8)
2324
+ @_documentation(visibility: private)
2325
+ #endif
2326
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
2327
+ let handle: UInt64 = try readInt(&buf)
2328
+ return try lift(handle)
2056
2329
  }
2330
+
2331
+ #if swift(>=5.8)
2332
+ @_documentation(visibility: private)
2333
+ #endif
2334
+ public static func lower(_ v: SwiftType) -> UInt64 {
2335
+ return handleMap.insert(obj: v)
2336
+ }
2337
+
2338
+ #if swift(>=5.8)
2339
+ @_documentation(visibility: private)
2340
+ #endif
2341
+ public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
2342
+ writeInt(&buf, lower(v))
2343
+ }
2344
+ }
2345
+
2346
+
2347
+ #if swift(>=5.8)
2348
+ @_documentation(visibility: private)
2349
+ #endif
2350
+ public func FfiConverterCallbackInterfaceAuthProfileStore_lift(_ handle: UInt64) throws -> AuthProfileStore {
2351
+ return try FfiConverterCallbackInterfaceAuthProfileStore.lift(handle)
2352
+ }
2353
+
2354
+ #if swift(>=5.8)
2355
+ @_documentation(visibility: private)
2356
+ #endif
2357
+ public func FfiConverterCallbackInterfaceAuthProfileStore_lower(_ v: AuthProfileStore) -> UInt64 {
2358
+ return FfiConverterCallbackInterfaceAuthProfileStore.lower(v)
2057
2359
  }
2058
2360
 
2059
2361
 
@@ -2065,7 +2367,7 @@ extension NativeAgentError: Foundation.LocalizedError {
2065
2367
  * that plugin is installed. When absent, the agent loop runs without
2066
2368
  * governance checks.
2067
2369
  */
2068
- public protocol GovernanceProvider : AnyObject {
2370
+ public protocol GovernanceProvider: AnyObject, Sendable {
2069
2371
 
2070
2372
  /**
2071
2373
  * Check if a tool call should proceed. Returns JSON verdict:
@@ -2102,20 +2404,29 @@ public protocol GovernanceProvider : AnyObject {
2102
2404
 
2103
2405
  }
2104
2406
 
2105
- // Magic number for the Rust proxy to call using the same mechanism as every other method,
2106
- // to free the callback once it's dropped by Rust.
2107
- private let IDX_CALLBACK_FREE: Int32 = 0
2108
- // Callback return codes
2109
- private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
2110
- private let UNIFFI_CALLBACK_ERROR: Int32 = 1
2111
- private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
2112
2407
 
2113
2408
  // Put the implementation in a struct so we don't pollute the top-level namespace
2114
2409
  fileprivate struct UniffiCallbackInterfaceGovernanceProvider {
2115
2410
 
2116
2411
  // Create the VTable using a series of closures.
2117
2412
  // Swift automatically converts these into C callback functions.
2118
- static var vtable: UniffiVTableCallbackInterfaceGovernanceProvider = UniffiVTableCallbackInterfaceGovernanceProvider(
2413
+ //
2414
+ // Store the vtable directly.
2415
+ static let vtable: UniffiVTableCallbackInterfaceGovernanceProvider = UniffiVTableCallbackInterfaceGovernanceProvider(
2416
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
2417
+ do {
2418
+ try FfiConverterCallbackInterfaceGovernanceProvider.handleMap.remove(handle: uniffiHandle)
2419
+ } catch {
2420
+ print("Uniffi callback interface GovernanceProvider: handle missing in uniffiFree")
2421
+ }
2422
+ },
2423
+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
2424
+ do {
2425
+ return try FfiConverterCallbackInterfaceGovernanceProvider.handleMap.clone(handle: uniffiHandle)
2426
+ } catch {
2427
+ fatalError("Uniffi callback interface GovernanceProvider: handle missing in uniffiClone")
2428
+ }
2429
+ },
2119
2430
  checkLoop: { (
2120
2431
  uniffiHandle: UInt64,
2121
2432
  toolName: RustBuffer,
@@ -2275,18 +2586,20 @@ fileprivate struct UniffiCallbackInterfaceGovernanceProvider {
2275
2586
  makeCall: makeCall,
2276
2587
  writeReturn: writeReturn
2277
2588
  )
2278
- },
2279
- uniffiFree: { (uniffiHandle: UInt64) -> () in
2280
- let result = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.remove(handle: uniffiHandle)
2281
- if result == nil {
2282
- print("Uniffi callback interface GovernanceProvider: handle missing in uniffiFree")
2283
- }
2284
2589
  }
2285
2590
  )
2591
+
2592
+ // Rust stores this pointer for future callback invocations, so it must live
2593
+ // for the process lifetime (not just for the init function call).
2594
+ static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceGovernanceProvider> = {
2595
+ let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceGovernanceProvider>.allocate(capacity: 1)
2596
+ ptr.initialize(to: vtable)
2597
+ return UnsafePointer(ptr)
2598
+ }()
2286
2599
  }
2287
2600
 
2288
2601
  private func uniffiCallbackInitGovernanceProvider() {
2289
- uniffi_native_agent_ffi_fn_init_callback_vtable_governanceprovider(&UniffiCallbackInterfaceGovernanceProvider.vtable)
2602
+ uniffi_native_agent_ffi_fn_init_callback_vtable_governanceprovider(UniffiCallbackInterfaceGovernanceProvider.vtablePtr)
2290
2603
  }
2291
2604
 
2292
2605
  // FfiConverter protocol for callback interfaces
@@ -2294,7 +2607,7 @@ private func uniffiCallbackInitGovernanceProvider() {
2294
2607
  @_documentation(visibility: private)
2295
2608
  #endif
2296
2609
  fileprivate struct FfiConverterCallbackInterfaceGovernanceProvider {
2297
- fileprivate static var handleMap = UniffiHandleMap<GovernanceProvider>()
2610
+ fileprivate static let handleMap = UniffiHandleMap<GovernanceProvider>()
2298
2611
  }
2299
2612
 
2300
2613
  #if swift(>=5.8)
@@ -2335,13 +2648,28 @@ extension FfiConverterCallbackInterfaceGovernanceProvider : FfiConverter {
2335
2648
  }
2336
2649
 
2337
2650
 
2651
+ #if swift(>=5.8)
2652
+ @_documentation(visibility: private)
2653
+ #endif
2654
+ public func FfiConverterCallbackInterfaceGovernanceProvider_lift(_ handle: UInt64) throws -> GovernanceProvider {
2655
+ return try FfiConverterCallbackInterfaceGovernanceProvider.lift(handle)
2656
+ }
2657
+
2658
+ #if swift(>=5.8)
2659
+ @_documentation(visibility: private)
2660
+ #endif
2661
+ public func FfiConverterCallbackInterfaceGovernanceProvider_lower(_ v: GovernanceProvider) -> UInt64 {
2662
+ return FfiConverterCallbackInterfaceGovernanceProvider.lower(v)
2663
+ }
2664
+
2665
+
2338
2666
 
2339
2667
 
2340
2668
  /**
2341
2669
  * Callback interface for memory operations (LanceDB or any vector store).
2342
2670
  * Implemented by Kotlin/Swift, which bridges to the actual memory backend.
2343
2671
  */
2344
- public protocol MemoryProvider : AnyObject {
2672
+ public protocol MemoryProvider: AnyObject, Sendable {
2345
2673
 
2346
2674
  func store(key: String, text: String, metadataJson: String?) -> String
2347
2675
 
@@ -2356,13 +2684,28 @@ public protocol MemoryProvider : AnyObject {
2356
2684
  }
2357
2685
 
2358
2686
 
2359
-
2360
2687
  // Put the implementation in a struct so we don't pollute the top-level namespace
2361
2688
  fileprivate struct UniffiCallbackInterfaceMemoryProvider {
2362
2689
 
2363
2690
  // Create the VTable using a series of closures.
2364
2691
  // Swift automatically converts these into C callback functions.
2365
- static var vtable: UniffiVTableCallbackInterfaceMemoryProvider = UniffiVTableCallbackInterfaceMemoryProvider(
2692
+ //
2693
+ // Store the vtable directly.
2694
+ static let vtable: UniffiVTableCallbackInterfaceMemoryProvider = UniffiVTableCallbackInterfaceMemoryProvider(
2695
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
2696
+ do {
2697
+ try FfiConverterCallbackInterfaceMemoryProvider.handleMap.remove(handle: uniffiHandle)
2698
+ } catch {
2699
+ print("Uniffi callback interface MemoryProvider: handle missing in uniffiFree")
2700
+ }
2701
+ },
2702
+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
2703
+ do {
2704
+ return try FfiConverterCallbackInterfaceMemoryProvider.handleMap.clone(handle: uniffiHandle)
2705
+ } catch {
2706
+ fatalError("Uniffi callback interface MemoryProvider: handle missing in uniffiClone")
2707
+ }
2708
+ },
2366
2709
  store: { (
2367
2710
  uniffiHandle: UInt64,
2368
2711
  key: RustBuffer,
@@ -2492,18 +2835,20 @@ fileprivate struct UniffiCallbackInterfaceMemoryProvider {
2492
2835
  makeCall: makeCall,
2493
2836
  writeReturn: writeReturn
2494
2837
  )
2495
- },
2496
- uniffiFree: { (uniffiHandle: UInt64) -> () in
2497
- let result = try? FfiConverterCallbackInterfaceMemoryProvider.handleMap.remove(handle: uniffiHandle)
2498
- if result == nil {
2499
- print("Uniffi callback interface MemoryProvider: handle missing in uniffiFree")
2500
- }
2501
2838
  }
2502
2839
  )
2840
+
2841
+ // Rust stores this pointer for future callback invocations, so it must live
2842
+ // for the process lifetime (not just for the init function call).
2843
+ static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceMemoryProvider> = {
2844
+ let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceMemoryProvider>.allocate(capacity: 1)
2845
+ ptr.initialize(to: vtable)
2846
+ return UnsafePointer(ptr)
2847
+ }()
2503
2848
  }
2504
2849
 
2505
2850
  private func uniffiCallbackInitMemoryProvider() {
2506
- uniffi_native_agent_ffi_fn_init_callback_vtable_memoryprovider(&UniffiCallbackInterfaceMemoryProvider.vtable)
2851
+ uniffi_native_agent_ffi_fn_init_callback_vtable_memoryprovider(UniffiCallbackInterfaceMemoryProvider.vtablePtr)
2507
2852
  }
2508
2853
 
2509
2854
  // FfiConverter protocol for callback interfaces
@@ -2511,7 +2856,7 @@ private func uniffiCallbackInitMemoryProvider() {
2511
2856
  @_documentation(visibility: private)
2512
2857
  #endif
2513
2858
  fileprivate struct FfiConverterCallbackInterfaceMemoryProvider {
2514
- fileprivate static var handleMap = UniffiHandleMap<MemoryProvider>()
2859
+ fileprivate static let handleMap = UniffiHandleMap<MemoryProvider>()
2515
2860
  }
2516
2861
 
2517
2862
  #if swift(>=5.8)
@@ -2552,12 +2897,27 @@ extension FfiConverterCallbackInterfaceMemoryProvider : FfiConverter {
2552
2897
  }
2553
2898
 
2554
2899
 
2900
+ #if swift(>=5.8)
2901
+ @_documentation(visibility: private)
2902
+ #endif
2903
+ public func FfiConverterCallbackInterfaceMemoryProvider_lift(_ handle: UInt64) throws -> MemoryProvider {
2904
+ return try FfiConverterCallbackInterfaceMemoryProvider.lift(handle)
2905
+ }
2906
+
2907
+ #if swift(>=5.8)
2908
+ @_documentation(visibility: private)
2909
+ #endif
2910
+ public func FfiConverterCallbackInterfaceMemoryProvider_lower(_ v: MemoryProvider) -> UInt64 {
2911
+ return FfiConverterCallbackInterfaceMemoryProvider.lower(v)
2912
+ }
2913
+
2914
+
2555
2915
 
2556
2916
 
2557
2917
  /**
2558
2918
  * Callback interface for events from the native agent.
2559
2919
  */
2560
- public protocol NativeEventCallback : AnyObject {
2920
+ public protocol NativeEventCallback: AnyObject, Sendable {
2561
2921
 
2562
2922
  /**
2563
2923
  * Called when the agent emits an event.
@@ -2569,13 +2929,28 @@ public protocol NativeEventCallback : AnyObject {
2569
2929
  }
2570
2930
 
2571
2931
 
2572
-
2573
2932
  // Put the implementation in a struct so we don't pollute the top-level namespace
2574
2933
  fileprivate struct UniffiCallbackInterfaceNativeEventCallback {
2575
2934
 
2576
2935
  // Create the VTable using a series of closures.
2577
2936
  // Swift automatically converts these into C callback functions.
2578
- static var vtable: UniffiVTableCallbackInterfaceNativeEventCallback = UniffiVTableCallbackInterfaceNativeEventCallback(
2937
+ //
2938
+ // Store the vtable directly.
2939
+ static let vtable: UniffiVTableCallbackInterfaceNativeEventCallback = UniffiVTableCallbackInterfaceNativeEventCallback(
2940
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
2941
+ do {
2942
+ try FfiConverterCallbackInterfaceNativeEventCallback.handleMap.remove(handle: uniffiHandle)
2943
+ } catch {
2944
+ print("Uniffi callback interface NativeEventCallback: handle missing in uniffiFree")
2945
+ }
2946
+ },
2947
+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
2948
+ do {
2949
+ return try FfiConverterCallbackInterfaceNativeEventCallback.handleMap.clone(handle: uniffiHandle)
2950
+ } catch {
2951
+ fatalError("Uniffi callback interface NativeEventCallback: handle missing in uniffiClone")
2952
+ }
2953
+ },
2579
2954
  onEvent: { (
2580
2955
  uniffiHandle: UInt64,
2581
2956
  eventType: RustBuffer,
@@ -2601,18 +2976,20 @@ fileprivate struct UniffiCallbackInterfaceNativeEventCallback {
2601
2976
  makeCall: makeCall,
2602
2977
  writeReturn: writeReturn
2603
2978
  )
2604
- },
2605
- uniffiFree: { (uniffiHandle: UInt64) -> () in
2606
- let result = try? FfiConverterCallbackInterfaceNativeEventCallback.handleMap.remove(handle: uniffiHandle)
2607
- if result == nil {
2608
- print("Uniffi callback interface NativeEventCallback: handle missing in uniffiFree")
2609
- }
2610
2979
  }
2611
2980
  )
2981
+
2982
+ // Rust stores this pointer for future callback invocations, so it must live
2983
+ // for the process lifetime (not just for the init function call).
2984
+ static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceNativeEventCallback> = {
2985
+ let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceNativeEventCallback>.allocate(capacity: 1)
2986
+ ptr.initialize(to: vtable)
2987
+ return UnsafePointer(ptr)
2988
+ }()
2612
2989
  }
2613
2990
 
2614
2991
  private func uniffiCallbackInitNativeEventCallback() {
2615
- uniffi_native_agent_ffi_fn_init_callback_vtable_nativeeventcallback(&UniffiCallbackInterfaceNativeEventCallback.vtable)
2992
+ uniffi_native_agent_ffi_fn_init_callback_vtable_nativeeventcallback(UniffiCallbackInterfaceNativeEventCallback.vtablePtr)
2616
2993
  }
2617
2994
 
2618
2995
  // FfiConverter protocol for callback interfaces
@@ -2620,7 +2997,7 @@ private func uniffiCallbackInitNativeEventCallback() {
2620
2997
  @_documentation(visibility: private)
2621
2998
  #endif
2622
2999
  fileprivate struct FfiConverterCallbackInterfaceNativeEventCallback {
2623
- fileprivate static var handleMap = UniffiHandleMap<NativeEventCallback>()
3000
+ fileprivate static let handleMap = UniffiHandleMap<NativeEventCallback>()
2624
3001
  }
2625
3002
 
2626
3003
  #if swift(>=5.8)
@@ -2661,25 +3038,55 @@ extension FfiConverterCallbackInterfaceNativeEventCallback : FfiConverter {
2661
3038
  }
2662
3039
 
2663
3040
 
3041
+ #if swift(>=5.8)
3042
+ @_documentation(visibility: private)
3043
+ #endif
3044
+ public func FfiConverterCallbackInterfaceNativeEventCallback_lift(_ handle: UInt64) throws -> NativeEventCallback {
3045
+ return try FfiConverterCallbackInterfaceNativeEventCallback.lift(handle)
3046
+ }
3047
+
3048
+ #if swift(>=5.8)
3049
+ @_documentation(visibility: private)
3050
+ #endif
3051
+ public func FfiConverterCallbackInterfaceNativeEventCallback_lower(_ v: NativeEventCallback) -> UInt64 {
3052
+ return FfiConverterCallbackInterfaceNativeEventCallback.lower(v)
3053
+ }
3054
+
3055
+
2664
3056
 
2665
3057
 
2666
3058
  /**
2667
3059
  * Callback interface for platform-native notification delivery.
2668
3060
  */
2669
- public protocol NativeNotifier : AnyObject {
3061
+ public protocol NativeNotifier: AnyObject, Sendable {
2670
3062
 
2671
3063
  func sendNotification(title: String, body: String, dataJson: String) -> String
2672
3064
 
2673
3065
  }
2674
3066
 
2675
3067
 
2676
-
2677
3068
  // Put the implementation in a struct so we don't pollute the top-level namespace
2678
3069
  fileprivate struct UniffiCallbackInterfaceNativeNotifier {
2679
3070
 
2680
3071
  // Create the VTable using a series of closures.
2681
3072
  // Swift automatically converts these into C callback functions.
2682
- static var vtable: UniffiVTableCallbackInterfaceNativeNotifier = UniffiVTableCallbackInterfaceNativeNotifier(
3073
+ //
3074
+ // Store the vtable directly.
3075
+ static let vtable: UniffiVTableCallbackInterfaceNativeNotifier = UniffiVTableCallbackInterfaceNativeNotifier(
3076
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
3077
+ do {
3078
+ try FfiConverterCallbackInterfaceNativeNotifier.handleMap.remove(handle: uniffiHandle)
3079
+ } catch {
3080
+ print("Uniffi callback interface NativeNotifier: handle missing in uniffiFree")
3081
+ }
3082
+ },
3083
+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
3084
+ do {
3085
+ return try FfiConverterCallbackInterfaceNativeNotifier.handleMap.clone(handle: uniffiHandle)
3086
+ } catch {
3087
+ fatalError("Uniffi callback interface NativeNotifier: handle missing in uniffiClone")
3088
+ }
3089
+ },
2683
3090
  sendNotification: { (
2684
3091
  uniffiHandle: UInt64,
2685
3092
  title: RustBuffer,
@@ -2707,18 +3114,20 @@ fileprivate struct UniffiCallbackInterfaceNativeNotifier {
2707
3114
  makeCall: makeCall,
2708
3115
  writeReturn: writeReturn
2709
3116
  )
2710
- },
2711
- uniffiFree: { (uniffiHandle: UInt64) -> () in
2712
- let result = try? FfiConverterCallbackInterfaceNativeNotifier.handleMap.remove(handle: uniffiHandle)
2713
- if result == nil {
2714
- print("Uniffi callback interface NativeNotifier: handle missing in uniffiFree")
2715
- }
2716
3117
  }
2717
3118
  )
3119
+
3120
+ // Rust stores this pointer for future callback invocations, so it must live
3121
+ // for the process lifetime (not just for the init function call).
3122
+ static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceNativeNotifier> = {
3123
+ let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceNativeNotifier>.allocate(capacity: 1)
3124
+ ptr.initialize(to: vtable)
3125
+ return UnsafePointer(ptr)
3126
+ }()
2718
3127
  }
2719
3128
 
2720
3129
  private func uniffiCallbackInitNativeNotifier() {
2721
- uniffi_native_agent_ffi_fn_init_callback_vtable_nativenotifier(&UniffiCallbackInterfaceNativeNotifier.vtable)
3130
+ uniffi_native_agent_ffi_fn_init_callback_vtable_nativenotifier(UniffiCallbackInterfaceNativeNotifier.vtablePtr)
2722
3131
  }
2723
3132
 
2724
3133
  // FfiConverter protocol for callback interfaces
@@ -2726,7 +3135,7 @@ private func uniffiCallbackInitNativeNotifier() {
2726
3135
  @_documentation(visibility: private)
2727
3136
  #endif
2728
3137
  fileprivate struct FfiConverterCallbackInterfaceNativeNotifier {
2729
- fileprivate static var handleMap = UniffiHandleMap<NativeNotifier>()
3138
+ fileprivate static let handleMap = UniffiHandleMap<NativeNotifier>()
2730
3139
  }
2731
3140
 
2732
3141
  #if swift(>=5.8)
@@ -2766,6 +3175,21 @@ extension FfiConverterCallbackInterfaceNativeNotifier : FfiConverter {
2766
3175
  }
2767
3176
  }
2768
3177
 
3178
+
3179
+ #if swift(>=5.8)
3180
+ @_documentation(visibility: private)
3181
+ #endif
3182
+ public func FfiConverterCallbackInterfaceNativeNotifier_lift(_ handle: UInt64) throws -> NativeNotifier {
3183
+ return try FfiConverterCallbackInterfaceNativeNotifier.lift(handle)
3184
+ }
3185
+
3186
+ #if swift(>=5.8)
3187
+ @_documentation(visibility: private)
3188
+ #endif
3189
+ public func FfiConverterCallbackInterfaceNativeNotifier_lower(_ v: NativeNotifier) -> UInt64 {
3190
+ return FfiConverterCallbackInterfaceNativeNotifier.lower(v)
3191
+ }
3192
+
2769
3193
  #if swift(>=5.8)
2770
3194
  @_documentation(visibility: private)
2771
3195
  #endif
@@ -2837,8 +3261,33 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
2837
3261
  }
2838
3262
  }
2839
3263
  }
2840
- public func createHandleFromPersistedConfig(configPath: String)throws -> NativeAgentHandle {
2841
- return try FfiConverterTypeNativeAgentHandle.lift(try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
3264
+
3265
+ #if swift(>=5.8)
3266
+ @_documentation(visibility: private)
3267
+ #endif
3268
+ fileprivate struct FfiConverterSequenceTypeNativeToolDescriptor: FfiConverterRustBuffer {
3269
+ typealias SwiftType = [NativeToolDescriptor]
3270
+
3271
+ public static func write(_ value: [NativeToolDescriptor], into buf: inout [UInt8]) {
3272
+ let len = Int32(value.count)
3273
+ writeInt(&buf, len)
3274
+ for item in value {
3275
+ FfiConverterTypeNativeToolDescriptor.write(item, into: &buf)
3276
+ }
3277
+ }
3278
+
3279
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [NativeToolDescriptor] {
3280
+ let len: Int32 = try readInt(&buf)
3281
+ var seq = [NativeToolDescriptor]()
3282
+ seq.reserveCapacity(Int(len))
3283
+ for _ in 0 ..< len {
3284
+ seq.append(try FfiConverterTypeNativeToolDescriptor.read(from: &buf))
3285
+ }
3286
+ return seq
3287
+ }
3288
+ }
3289
+ public func createHandleFromPersistedConfig(configPath: String)throws -> NativeAgentHandle {
3290
+ return try FfiConverterTypeNativeAgentHandle_lift(try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
2842
3291
  uniffi_native_agent_ffi_fn_func_create_handle_from_persisted_config(
2843
3292
  FfiConverterString.lower(configPath),$0
2844
3293
  )
@@ -2847,9 +3296,9 @@ public func createHandleFromPersistedConfig(configPath: String)throws -> Native
2847
3296
  /**
2848
3297
  * Standalone workspace initialization for cold-start paths.
2849
3298
  */
2850
- public func initWorkspace(config: InitConfig)throws {try rustCallWithError(FfiConverterTypeNativeAgentError.lift) {
3299
+ public func initWorkspace(config: InitConfig)throws {try rustCallWithError(FfiConverterTypeNativeAgentError_lift) {
2851
3300
  uniffi_native_agent_ffi_fn_func_init_workspace(
2852
- FfiConverterTypeInitConfig.lower(config),$0
3301
+ FfiConverterTypeInitConfig_lower(config),$0
2853
3302
  )
2854
3303
  }
2855
3304
  }
@@ -2861,9 +3310,9 @@ private enum InitializationResult {
2861
3310
  }
2862
3311
  // Use a global variable to perform the versioning checks. Swift ensures that
2863
3312
  // the code inside is only computed once.
2864
- private var initializationResult: InitializationResult = {
3313
+ private let initializationResult: InitializationResult = {
2865
3314
  // Get the bindings contract version from our ComponentInterface
2866
- let bindings_contract_version = 26
3315
+ let bindings_contract_version = 30
2867
3316
  // Get the scaffolding contract version by calling the into the dylib
2868
3317
  let scaffolding_contract_version = ffi_native_agent_ffi_uniffi_contract_version()
2869
3318
  if bindings_contract_version != scaffolding_contract_version {
@@ -2872,7 +3321,7 @@ private var initializationResult: InitializationResult = {
2872
3321
  if (uniffi_native_agent_ffi_checksum_func_create_handle_from_persisted_config() != 41643) {
2873
3322
  return InitializationResult.apiChecksumMismatch
2874
3323
  }
2875
- if (uniffi_native_agent_ffi_checksum_func_init_workspace() != 39423) {
3324
+ if (uniffi_native_agent_ffi_checksum_func_init_workspace() != 313) {
2876
3325
  return InitializationResult.apiChecksumMismatch
2877
3326
  }
2878
3327
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_abort() != 58908) {
@@ -2890,6 +3339,9 @@ private var initializationResult: InitializationResult = {
2890
3339
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_delete_auth() != 2640) {
2891
3340
  return InitializationResult.apiChecksumMismatch
2892
3341
  }
3342
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_dispatch_agent_command_json() != 26137) {
3343
+ return InitializationResult.apiChecksumMismatch
3344
+ }
2893
3345
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_end_skill() != 49984) {
2894
3346
  return InitializationResult.apiChecksumMismatch
2895
3347
  }
@@ -2899,10 +3351,10 @@ private var initializationResult: InitializationResult = {
2899
3351
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_follow_up() != 816) {
2900
3352
  return InitializationResult.apiChecksumMismatch
2901
3353
  }
2902
- if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_status() != 31550) {
3354
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_status() != 19426) {
2903
3355
  return InitializationResult.apiChecksumMismatch
2904
3356
  }
2905
- if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_token() != 58380) {
3357
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_token() != 36642) {
2906
3358
  return InitializationResult.apiChecksumMismatch
2907
3359
  }
2908
3360
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_heartbeat_config() != 1627) {
@@ -2926,6 +3378,9 @@ private var initializationResult: InitializationResult = {
2926
3378
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_cron_runs() != 27743) {
2927
3379
  return InitializationResult.apiChecksumMismatch
2928
3380
  }
3381
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_native_tools() != 614) {
3382
+ return InitializationResult.apiChecksumMismatch
3383
+ }
2929
3384
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_sessions() != 20894) {
2930
3385
  return InitializationResult.apiChecksumMismatch
2931
3386
  }
@@ -2944,7 +3399,7 @@ private var initializationResult: InitializationResult = {
2944
3399
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_persist_config() != 63110) {
2945
3400
  return InitializationResult.apiChecksumMismatch
2946
3401
  }
2947
- if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_refresh_token() != 13290) {
3402
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_refresh_token() != 43469) {
2948
3403
  return InitializationResult.apiChecksumMismatch
2949
3404
  }
2950
3405
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_remove_cron_job() != 55519) {
@@ -2977,7 +3432,10 @@ private var initializationResult: InitializationResult = {
2977
3432
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_seed_tool_permissions() != 39225) {
2978
3433
  return InitializationResult.apiChecksumMismatch
2979
3434
  }
2980
- if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_send_message() != 53296) {
3435
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_send_message() != 35046) {
3436
+ return InitializationResult.apiChecksumMismatch
3437
+ }
3438
+ if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_serialize_agent_event_json() != 40873) {
2981
3439
  return InitializationResult.apiChecksumMismatch
2982
3440
  }
2983
3441
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_auth_key() != 1639) {
@@ -3019,7 +3477,7 @@ private var initializationResult: InitializationResult = {
3019
3477
  if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_skill() != 42452) {
3020
3478
  return InitializationResult.apiChecksumMismatch
3021
3479
  }
3022
- if (uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new() != 18383) {
3480
+ if (uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new() != 28156) {
3023
3481
  return InitializationResult.apiChecksumMismatch
3024
3482
  }
3025
3483
  if (uniffi_native_agent_ffi_checksum_method_governanceprovider_check_loop() != 64194) {
@@ -3061,7 +3519,14 @@ private var initializationResult: InitializationResult = {
3061
3519
  if (uniffi_native_agent_ffi_checksum_method_nativenotifier_send_notification() != 9573) {
3062
3520
  return InitializationResult.apiChecksumMismatch
3063
3521
  }
3522
+ if (uniffi_native_agent_ffi_checksum_method_authprofilestore_load() != 44333) {
3523
+ return InitializationResult.apiChecksumMismatch
3524
+ }
3525
+ if (uniffi_native_agent_ffi_checksum_method_authprofilestore_save() != 41441) {
3526
+ return InitializationResult.apiChecksumMismatch
3527
+ }
3064
3528
 
3529
+ uniffiCallbackInitAuthProfileStore()
3065
3530
  uniffiCallbackInitGovernanceProvider()
3066
3531
  uniffiCallbackInitMemoryProvider()
3067
3532
  uniffiCallbackInitNativeEventCallback()
@@ -3069,7 +3534,9 @@ private var initializationResult: InitializationResult = {
3069
3534
  return InitializationResult.ok
3070
3535
  }()
3071
3536
 
3072
- private func uniffiEnsureInitialized() {
3537
+ // Make the ensure init function public so that other modules which have external type references to
3538
+ // our types can call it.
3539
+ public func uniffiEnsureNativeAgentFfiInitialized() {
3073
3540
  switch initializationResult {
3074
3541
  case .ok:
3075
3542
  break