capacitor-native-agent 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -23
- package/android/src/main/java/com/t6x/plugins/nativeagent/NativeAgentPlugin.kt +8 -0
- package/android/src/main/java/uniffi/native_agent_ffi/native_agent_ffi.kt +22 -2
- package/android/src/main/jniLibs/arm64-v8a/libnative_agent_ffi.so +0 -0
- package/dist/esm/definitions.d.ts +22 -0
- package/dist/esm/definitions.d.ts.map +1 -1
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64/Headers/native_agent_ffi/native_agent_ffi.swift +399 -17
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64/Headers/native_agent_ffi/native_agent_ffiFFI.h +109 -2
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64/libnative_agent_ffi.a +0 -0
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64-simulator/Headers/native_agent_ffi/native_agent_ffi.swift +399 -17
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64-simulator/Headers/native_agent_ffi/native_agent_ffiFFI.h +109 -2
- package/ios/Frameworks/NativeAgentFFI.xcframework/ios-arm64-simulator/libnative_agent_ffi.a +0 -0
- package/ios/Sources/NativeAgentPlugin/Generated/native_agent_ffi.swift +360 -9
- package/ios/Sources/NativeAgentPlugin/Generated/native_agent_ffiFFI.h +107 -0
- package/ios/Sources/NativeAgentPlugin/NativeAgentPlugin.swift +10 -2
- package/package.json +1 -1
|
@@ -250,6 +250,48 @@ typedef struct UniffiForeignFutureStructVoid {
|
|
|
250
250
|
typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid
|
|
251
251
|
);
|
|
252
252
|
|
|
253
|
+
#endif
|
|
254
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD0
|
|
255
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD0
|
|
256
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod0)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull,
|
|
257
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
#endif
|
|
261
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD1
|
|
262
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD1
|
|
263
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod1)(uint64_t, RustBuffer, RustBuffer, RustBuffer, RustBuffer* _Nonnull,
|
|
264
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
#endif
|
|
268
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD2
|
|
269
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD2
|
|
270
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod2)(uint64_t, RustBuffer, RustBuffer, RustBuffer, RustBuffer, void* _Nonnull,
|
|
271
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
#endif
|
|
275
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD3
|
|
276
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD3
|
|
277
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod3)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull,
|
|
278
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
#endif
|
|
282
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD4
|
|
283
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD4
|
|
284
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod4)(uint64_t, void* _Nonnull,
|
|
285
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
#endif
|
|
289
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD5
|
|
290
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER_METHOD5
|
|
291
|
+
typedef void (*UniffiCallbackInterfaceGovernanceProviderMethod5)(uint64_t, RustBuffer, uint32_t, uint32_t, void* _Nonnull,
|
|
292
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
293
|
+
);
|
|
294
|
+
|
|
253
295
|
#endif
|
|
254
296
|
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_MEMORY_PROVIDER_METHOD0
|
|
255
297
|
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_MEMORY_PROVIDER_METHOD0
|
|
@@ -299,6 +341,19 @@ typedef void (*UniffiCallbackInterfaceNativeNotifierMethod0)(uint64_t, RustBuffe
|
|
|
299
341
|
RustCallStatus *_Nonnull uniffiCallStatus
|
|
300
342
|
);
|
|
301
343
|
|
|
344
|
+
#endif
|
|
345
|
+
#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER
|
|
346
|
+
#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_GOVERNANCE_PROVIDER
|
|
347
|
+
typedef struct UniffiVTableCallbackInterfaceGovernanceProvider {
|
|
348
|
+
UniffiCallbackInterfaceGovernanceProviderMethod0 _Nonnull checkLoop;
|
|
349
|
+
UniffiCallbackInterfaceGovernanceProviderMethod1 _Nonnull recordOutcome;
|
|
350
|
+
UniffiCallbackInterfaceGovernanceProviderMethod2 _Nonnull recordAudit;
|
|
351
|
+
UniffiCallbackInterfaceGovernanceProviderMethod3 _Nonnull checkSink;
|
|
352
|
+
UniffiCallbackInterfaceGovernanceProviderMethod4 _Nonnull reset;
|
|
353
|
+
UniffiCallbackInterfaceGovernanceProviderMethod5 _Nonnull recordUsage;
|
|
354
|
+
UniffiCallbackInterfaceFree _Nonnull uniffiFree;
|
|
355
|
+
} UniffiVTableCallbackInterfaceGovernanceProvider;
|
|
356
|
+
|
|
302
357
|
#endif
|
|
303
358
|
#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MEMORY_PROVIDER
|
|
304
359
|
#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MEMORY_PROVIDER
|
|
@@ -500,7 +555,7 @@ uint32_t uniffi_native_agent_ffi_fn_method_nativeagenthandle_restart_mcp(void*_N
|
|
|
500
555
|
#endif
|
|
501
556
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_RESUME_SESSION
|
|
502
557
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_RESUME_SESSION
|
|
503
|
-
|
|
558
|
+
int8_t uniffi_native_agent_ffi_fn_method_nativeagenthandle_resume_session(void*_Nonnull ptr, RustBuffer session_key, RustBuffer agent_id, RustBuffer messages_json, RustBuffer provider, RustBuffer model, RustCallStatus *_Nonnull out_status
|
|
504
559
|
);
|
|
505
560
|
#endif
|
|
506
561
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_RUN_CRON_JOB
|
|
@@ -520,7 +575,7 @@ RustBuffer uniffi_native_agent_ffi_fn_method_nativeagenthandle_send_message(void
|
|
|
520
575
|
#endif
|
|
521
576
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_AUTH_KEY
|
|
522
577
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_AUTH_KEY
|
|
523
|
-
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(void*_Nonnull ptr, RustBuffer key, RustBuffer provider, RustBuffer auth_type, RustCallStatus *_Nonnull out_status
|
|
578
|
+
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(void*_Nonnull ptr, RustBuffer key, RustBuffer provider, RustBuffer auth_type, RustBuffer refresh, RustBuffer expires_at, RustCallStatus *_Nonnull out_status
|
|
524
579
|
);
|
|
525
580
|
#endif
|
|
526
581
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_EVENT_CALLBACK
|
|
@@ -528,6 +583,11 @@ void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(void*_Nonn
|
|
|
528
583
|
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_event_callback(void*_Nonnull ptr, uint64_t callback, RustCallStatus *_Nonnull out_status
|
|
529
584
|
);
|
|
530
585
|
#endif
|
|
586
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_GOVERNANCE_PROVIDER
|
|
587
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_GOVERNANCE_PROVIDER
|
|
588
|
+
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_governance_provider(void*_Nonnull ptr, uint64_t provider, RustCallStatus *_Nonnull out_status
|
|
589
|
+
);
|
|
590
|
+
#endif
|
|
531
591
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_HEARTBEAT_CONFIG
|
|
532
592
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_METHOD_NATIVEAGENTHANDLE_SET_HEARTBEAT_CONFIG
|
|
533
593
|
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_heartbeat_config(void*_Nonnull ptr, RustBuffer config_json, RustCallStatus *_Nonnull out_status
|
|
@@ -578,6 +638,11 @@ void uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_cron_job(void*_N
|
|
|
578
638
|
void uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_skill(void*_Nonnull ptr, RustBuffer id, RustBuffer patch_json, RustCallStatus *_Nonnull out_status
|
|
579
639
|
);
|
|
580
640
|
#endif
|
|
641
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_INIT_CALLBACK_VTABLE_GOVERNANCEPROVIDER
|
|
642
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_INIT_CALLBACK_VTABLE_GOVERNANCEPROVIDER
|
|
643
|
+
void uniffi_native_agent_ffi_fn_init_callback_vtable_governanceprovider(UniffiVTableCallbackInterfaceGovernanceProvider* _Nonnull vtable
|
|
644
|
+
);
|
|
645
|
+
#endif
|
|
581
646
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_INIT_CALLBACK_VTABLE_MEMORYPROVIDER
|
|
582
647
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_FN_INIT_CALLBACK_VTABLE_MEMORYPROVIDER
|
|
583
648
|
void uniffi_native_agent_ffi_fn_init_callback_vtable_memoryprovider(UniffiVTableCallbackInterfaceMemoryProvider* _Nonnull vtable
|
|
@@ -1115,6 +1180,12 @@ uint16_t uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_auth_key(
|
|
|
1115
1180
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_NATIVEAGENTHANDLE_SET_EVENT_CALLBACK
|
|
1116
1181
|
uint16_t uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_event_callback(void
|
|
1117
1182
|
|
|
1183
|
+
);
|
|
1184
|
+
#endif
|
|
1185
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_NATIVEAGENTHANDLE_SET_GOVERNANCE_PROVIDER
|
|
1186
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_NATIVEAGENTHANDLE_SET_GOVERNANCE_PROVIDER
|
|
1187
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_governance_provider(void
|
|
1188
|
+
|
|
1118
1189
|
);
|
|
1119
1190
|
#endif
|
|
1120
1191
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_NATIVEAGENTHANDLE_SET_HEARTBEAT_CONFIG
|
|
@@ -1181,6 +1252,42 @@ uint16_t uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_skill(
|
|
|
1181
1252
|
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_CONSTRUCTOR_NATIVEAGENTHANDLE_NEW
|
|
1182
1253
|
uint16_t uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new(void
|
|
1183
1254
|
|
|
1255
|
+
);
|
|
1256
|
+
#endif
|
|
1257
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_CHECK_LOOP
|
|
1258
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_CHECK_LOOP
|
|
1259
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_check_loop(void
|
|
1260
|
+
|
|
1261
|
+
);
|
|
1262
|
+
#endif
|
|
1263
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_OUTCOME
|
|
1264
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_OUTCOME
|
|
1265
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_record_outcome(void
|
|
1266
|
+
|
|
1267
|
+
);
|
|
1268
|
+
#endif
|
|
1269
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_AUDIT
|
|
1270
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_AUDIT
|
|
1271
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_record_audit(void
|
|
1272
|
+
|
|
1273
|
+
);
|
|
1274
|
+
#endif
|
|
1275
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_CHECK_SINK
|
|
1276
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_CHECK_SINK
|
|
1277
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_check_sink(void
|
|
1278
|
+
|
|
1279
|
+
);
|
|
1280
|
+
#endif
|
|
1281
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RESET
|
|
1282
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RESET
|
|
1283
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_reset(void
|
|
1284
|
+
|
|
1285
|
+
);
|
|
1286
|
+
#endif
|
|
1287
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_USAGE
|
|
1288
|
+
#define UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_GOVERNANCEPROVIDER_RECORD_USAGE
|
|
1289
|
+
uint16_t uniffi_native_agent_ffi_checksum_method_governanceprovider_record_usage(void
|
|
1290
|
+
|
|
1184
1291
|
);
|
|
1185
1292
|
#endif
|
|
1186
1293
|
#ifndef UNIFFI_FFIDEF_UNIFFI_NATIVE_AGENT_FFI_CHECKSUM_METHOD_MEMORYPROVIDER_STORE
|
|
Binary file
|
|
@@ -687,6 +687,12 @@ public protocol NativeAgentHandleProtocol : AnyObject {
|
|
|
687
687
|
*/
|
|
688
688
|
func setEventCallback(callback: NativeEventCallback) throws
|
|
689
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Set the optional governance provider (taint, audit, loop-guard, cost tracking).
|
|
692
|
+
* Typically called by capacitor-agent-os when it auto-registers at init time.
|
|
693
|
+
*/
|
|
694
|
+
func setGovernanceProvider(provider: GovernanceProvider) throws
|
|
695
|
+
|
|
690
696
|
/**
|
|
691
697
|
* Set heartbeat config.
|
|
692
698
|
*/
|
|
@@ -1195,6 +1201,17 @@ open func setEventCallback(callback: NativeEventCallback)throws {try rustCallWi
|
|
|
1195
1201
|
FfiConverterCallbackInterfaceNativeEventCallback.lower(callback),$0
|
|
1196
1202
|
)
|
|
1197
1203
|
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Set the optional governance provider (taint, audit, loop-guard, cost tracking).
|
|
1208
|
+
* Typically called by capacitor-agent-os when it auto-registers at init time.
|
|
1209
|
+
*/
|
|
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
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1198
1215
|
}
|
|
1199
1216
|
|
|
1200
1217
|
/**
|
|
@@ -1516,6 +1533,20 @@ public struct InitConfig {
|
|
|
1516
1533
|
* Path to auth-profiles.json.
|
|
1517
1534
|
*/
|
|
1518
1535
|
public var authProfilesPath: String
|
|
1536
|
+
/**
|
|
1537
|
+
* Configured default LLM provider for this agent. When a per-call
|
|
1538
|
+
* `SendMessageParams.provider` is unset, the resolver falls back to
|
|
1539
|
+
* this value. `None` falls through to the hardcoded "anthropic"
|
|
1540
|
+
* safety net — which any properly-configured install should never hit.
|
|
1541
|
+
*/
|
|
1542
|
+
public var defaultProvider: String?
|
|
1543
|
+
/**
|
|
1544
|
+
* Configured default model. Only used when the resolver also took
|
|
1545
|
+
* `default_provider` (i.e. the caller didn't override provider) — if
|
|
1546
|
+
* provider is overridden, the per-provider default model is used
|
|
1547
|
+
* instead, since model strings are tied to providers.
|
|
1548
|
+
*/
|
|
1549
|
+
public var defaultModel: String?
|
|
1519
1550
|
|
|
1520
1551
|
// Default memberwise initializers are never public by default, so we
|
|
1521
1552
|
// declare one manually.
|
|
@@ -1528,10 +1559,24 @@ public struct InitConfig {
|
|
|
1528
1559
|
*/workspacePath: String,
|
|
1529
1560
|
/**
|
|
1530
1561
|
* Path to auth-profiles.json.
|
|
1531
|
-
*/authProfilesPath: String
|
|
1562
|
+
*/authProfilesPath: String,
|
|
1563
|
+
/**
|
|
1564
|
+
* Configured default LLM provider for this agent. When a per-call
|
|
1565
|
+
* `SendMessageParams.provider` is unset, the resolver falls back to
|
|
1566
|
+
* this value. `None` falls through to the hardcoded "anthropic"
|
|
1567
|
+
* safety net — which any properly-configured install should never hit.
|
|
1568
|
+
*/defaultProvider: String?,
|
|
1569
|
+
/**
|
|
1570
|
+
* Configured default model. Only used when the resolver also took
|
|
1571
|
+
* `default_provider` (i.e. the caller didn't override provider) — if
|
|
1572
|
+
* provider is overridden, the per-provider default model is used
|
|
1573
|
+
* instead, since model strings are tied to providers.
|
|
1574
|
+
*/defaultModel: String?) {
|
|
1532
1575
|
self.dbPath = dbPath
|
|
1533
1576
|
self.workspacePath = workspacePath
|
|
1534
1577
|
self.authProfilesPath = authProfilesPath
|
|
1578
|
+
self.defaultProvider = defaultProvider
|
|
1579
|
+
self.defaultModel = defaultModel
|
|
1535
1580
|
}
|
|
1536
1581
|
}
|
|
1537
1582
|
|
|
@@ -1548,6 +1593,12 @@ extension InitConfig: Equatable, Hashable {
|
|
|
1548
1593
|
if lhs.authProfilesPath != rhs.authProfilesPath {
|
|
1549
1594
|
return false
|
|
1550
1595
|
}
|
|
1596
|
+
if lhs.defaultProvider != rhs.defaultProvider {
|
|
1597
|
+
return false
|
|
1598
|
+
}
|
|
1599
|
+
if lhs.defaultModel != rhs.defaultModel {
|
|
1600
|
+
return false
|
|
1601
|
+
}
|
|
1551
1602
|
return true
|
|
1552
1603
|
}
|
|
1553
1604
|
|
|
@@ -1555,6 +1606,8 @@ extension InitConfig: Equatable, Hashable {
|
|
|
1555
1606
|
hasher.combine(dbPath)
|
|
1556
1607
|
hasher.combine(workspacePath)
|
|
1557
1608
|
hasher.combine(authProfilesPath)
|
|
1609
|
+
hasher.combine(defaultProvider)
|
|
1610
|
+
hasher.combine(defaultModel)
|
|
1558
1611
|
}
|
|
1559
1612
|
}
|
|
1560
1613
|
|
|
@@ -1568,7 +1621,9 @@ public struct FfiConverterTypeInitConfig: FfiConverterRustBuffer {
|
|
|
1568
1621
|
try InitConfig(
|
|
1569
1622
|
dbPath: FfiConverterString.read(from: &buf),
|
|
1570
1623
|
workspacePath: FfiConverterString.read(from: &buf),
|
|
1571
|
-
authProfilesPath: FfiConverterString.read(from: &buf)
|
|
1624
|
+
authProfilesPath: FfiConverterString.read(from: &buf),
|
|
1625
|
+
defaultProvider: FfiConverterOptionString.read(from: &buf),
|
|
1626
|
+
defaultModel: FfiConverterOptionString.read(from: &buf)
|
|
1572
1627
|
)
|
|
1573
1628
|
}
|
|
1574
1629
|
|
|
@@ -1576,6 +1631,8 @@ public struct FfiConverterTypeInitConfig: FfiConverterRustBuffer {
|
|
|
1576
1631
|
FfiConverterString.write(value.dbPath, into: &buf)
|
|
1577
1632
|
FfiConverterString.write(value.workspacePath, into: &buf)
|
|
1578
1633
|
FfiConverterString.write(value.authProfilesPath, into: &buf)
|
|
1634
|
+
FfiConverterOptionString.write(value.defaultProvider, into: &buf)
|
|
1635
|
+
FfiConverterOptionString.write(value.defaultModel, into: &buf)
|
|
1579
1636
|
}
|
|
1580
1637
|
}
|
|
1581
1638
|
|
|
@@ -2002,6 +2059,284 @@ extension NativeAgentError: Foundation.LocalizedError {
|
|
|
2002
2059
|
|
|
2003
2060
|
|
|
2004
2061
|
|
|
2062
|
+
/**
|
|
2063
|
+
* Optional governance provider for security, audit, and loop-guard checks.
|
|
2064
|
+
* Implemented by Kotlin/Swift — typically backed by capacitor-agent-os when
|
|
2065
|
+
* that plugin is installed. When absent, the agent loop runs without
|
|
2066
|
+
* governance checks.
|
|
2067
|
+
*/
|
|
2068
|
+
public protocol GovernanceProvider : AnyObject {
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* Check if a tool call should proceed. Returns JSON verdict:
|
|
2072
|
+
* `{"type":"Allow"}` | `{"type":"Warn","reason":"..."}` |
|
|
2073
|
+
* `{"type":"Block","reason":"..."}` | `{"type":"CircuitBreak","reason":"..."}`
|
|
2074
|
+
*/
|
|
2075
|
+
func checkLoop(toolName: String, paramsJson: String) -> String
|
|
2076
|
+
|
|
2077
|
+
/**
|
|
2078
|
+
* Record tool outcome for loop detection. Returns optional warning string.
|
|
2079
|
+
*/
|
|
2080
|
+
func recordOutcome(toolName: String, paramsJson: String, result: String) -> String?
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* Record an audit trail entry.
|
|
2084
|
+
*/
|
|
2085
|
+
func recordAudit(agentId: String, action: String, detail: String, outcome: String)
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Check if content is tainted before passing to LLM. Returns JSON:
|
|
2089
|
+
* `{"blocked":true/false,"reason":"...","matchedLabels":[...]}`
|
|
2090
|
+
*/
|
|
2091
|
+
func checkSink(sinkType: String, content: String) -> String
|
|
2092
|
+
|
|
2093
|
+
/**
|
|
2094
|
+
* Reset loop guard state (e.g. on new session).
|
|
2095
|
+
*/
|
|
2096
|
+
func reset()
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* Record token usage for cost tracking.
|
|
2100
|
+
*/
|
|
2101
|
+
func recordUsage(modelId: String, inputTokens: UInt32, outputTokens: UInt32)
|
|
2102
|
+
|
|
2103
|
+
}
|
|
2104
|
+
|
|
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
|
+
|
|
2113
|
+
// Put the implementation in a struct so we don't pollute the top-level namespace
|
|
2114
|
+
fileprivate struct UniffiCallbackInterfaceGovernanceProvider {
|
|
2115
|
+
|
|
2116
|
+
// Create the VTable using a series of closures.
|
|
2117
|
+
// Swift automatically converts these into C callback functions.
|
|
2118
|
+
static var vtable: UniffiVTableCallbackInterfaceGovernanceProvider = UniffiVTableCallbackInterfaceGovernanceProvider(
|
|
2119
|
+
checkLoop: { (
|
|
2120
|
+
uniffiHandle: UInt64,
|
|
2121
|
+
toolName: RustBuffer,
|
|
2122
|
+
paramsJson: RustBuffer,
|
|
2123
|
+
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
|
|
2124
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2125
|
+
) in
|
|
2126
|
+
let makeCall = {
|
|
2127
|
+
() throws -> String in
|
|
2128
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2129
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2130
|
+
}
|
|
2131
|
+
return uniffiObj.checkLoop(
|
|
2132
|
+
toolName: try FfiConverterString.lift(toolName),
|
|
2133
|
+
paramsJson: try FfiConverterString.lift(paramsJson)
|
|
2134
|
+
)
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) }
|
|
2139
|
+
uniffiTraitInterfaceCall(
|
|
2140
|
+
callStatus: uniffiCallStatus,
|
|
2141
|
+
makeCall: makeCall,
|
|
2142
|
+
writeReturn: writeReturn
|
|
2143
|
+
)
|
|
2144
|
+
},
|
|
2145
|
+
recordOutcome: { (
|
|
2146
|
+
uniffiHandle: UInt64,
|
|
2147
|
+
toolName: RustBuffer,
|
|
2148
|
+
paramsJson: RustBuffer,
|
|
2149
|
+
result: RustBuffer,
|
|
2150
|
+
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
|
|
2151
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2152
|
+
) in
|
|
2153
|
+
let makeCall = {
|
|
2154
|
+
() throws -> String? in
|
|
2155
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2156
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2157
|
+
}
|
|
2158
|
+
return uniffiObj.recordOutcome(
|
|
2159
|
+
toolName: try FfiConverterString.lift(toolName),
|
|
2160
|
+
paramsJson: try FfiConverterString.lift(paramsJson),
|
|
2161
|
+
result: try FfiConverterString.lift(result)
|
|
2162
|
+
)
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionString.lower($0) }
|
|
2167
|
+
uniffiTraitInterfaceCall(
|
|
2168
|
+
callStatus: uniffiCallStatus,
|
|
2169
|
+
makeCall: makeCall,
|
|
2170
|
+
writeReturn: writeReturn
|
|
2171
|
+
)
|
|
2172
|
+
},
|
|
2173
|
+
recordAudit: { (
|
|
2174
|
+
uniffiHandle: UInt64,
|
|
2175
|
+
agentId: RustBuffer,
|
|
2176
|
+
action: RustBuffer,
|
|
2177
|
+
detail: RustBuffer,
|
|
2178
|
+
outcome: RustBuffer,
|
|
2179
|
+
uniffiOutReturn: UnsafeMutableRawPointer,
|
|
2180
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2181
|
+
) in
|
|
2182
|
+
let makeCall = {
|
|
2183
|
+
() throws -> () in
|
|
2184
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2185
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2186
|
+
}
|
|
2187
|
+
return uniffiObj.recordAudit(
|
|
2188
|
+
agentId: try FfiConverterString.lift(agentId),
|
|
2189
|
+
action: try FfiConverterString.lift(action),
|
|
2190
|
+
detail: try FfiConverterString.lift(detail),
|
|
2191
|
+
outcome: try FfiConverterString.lift(outcome)
|
|
2192
|
+
)
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
let writeReturn = { () }
|
|
2197
|
+
uniffiTraitInterfaceCall(
|
|
2198
|
+
callStatus: uniffiCallStatus,
|
|
2199
|
+
makeCall: makeCall,
|
|
2200
|
+
writeReturn: writeReturn
|
|
2201
|
+
)
|
|
2202
|
+
},
|
|
2203
|
+
checkSink: { (
|
|
2204
|
+
uniffiHandle: UInt64,
|
|
2205
|
+
sinkType: RustBuffer,
|
|
2206
|
+
content: RustBuffer,
|
|
2207
|
+
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
|
|
2208
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2209
|
+
) in
|
|
2210
|
+
let makeCall = {
|
|
2211
|
+
() throws -> String in
|
|
2212
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2213
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2214
|
+
}
|
|
2215
|
+
return uniffiObj.checkSink(
|
|
2216
|
+
sinkType: try FfiConverterString.lift(sinkType),
|
|
2217
|
+
content: try FfiConverterString.lift(content)
|
|
2218
|
+
)
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) }
|
|
2223
|
+
uniffiTraitInterfaceCall(
|
|
2224
|
+
callStatus: uniffiCallStatus,
|
|
2225
|
+
makeCall: makeCall,
|
|
2226
|
+
writeReturn: writeReturn
|
|
2227
|
+
)
|
|
2228
|
+
},
|
|
2229
|
+
reset: { (
|
|
2230
|
+
uniffiHandle: UInt64,
|
|
2231
|
+
uniffiOutReturn: UnsafeMutableRawPointer,
|
|
2232
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2233
|
+
) in
|
|
2234
|
+
let makeCall = {
|
|
2235
|
+
() throws -> () in
|
|
2236
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2237
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2238
|
+
}
|
|
2239
|
+
return uniffiObj.reset(
|
|
2240
|
+
)
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
let writeReturn = { () }
|
|
2245
|
+
uniffiTraitInterfaceCall(
|
|
2246
|
+
callStatus: uniffiCallStatus,
|
|
2247
|
+
makeCall: makeCall,
|
|
2248
|
+
writeReturn: writeReturn
|
|
2249
|
+
)
|
|
2250
|
+
},
|
|
2251
|
+
recordUsage: { (
|
|
2252
|
+
uniffiHandle: UInt64,
|
|
2253
|
+
modelId: RustBuffer,
|
|
2254
|
+
inputTokens: UInt32,
|
|
2255
|
+
outputTokens: UInt32,
|
|
2256
|
+
uniffiOutReturn: UnsafeMutableRawPointer,
|
|
2257
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
2258
|
+
) in
|
|
2259
|
+
let makeCall = {
|
|
2260
|
+
() throws -> () in
|
|
2261
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceGovernanceProvider.handleMap.get(handle: uniffiHandle) else {
|
|
2262
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
2263
|
+
}
|
|
2264
|
+
return uniffiObj.recordUsage(
|
|
2265
|
+
modelId: try FfiConverterString.lift(modelId),
|
|
2266
|
+
inputTokens: try FfiConverterUInt32.lift(inputTokens),
|
|
2267
|
+
outputTokens: try FfiConverterUInt32.lift(outputTokens)
|
|
2268
|
+
)
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
|
|
2272
|
+
let writeReturn = { () }
|
|
2273
|
+
uniffiTraitInterfaceCall(
|
|
2274
|
+
callStatus: uniffiCallStatus,
|
|
2275
|
+
makeCall: makeCall,
|
|
2276
|
+
writeReturn: writeReturn
|
|
2277
|
+
)
|
|
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
|
+
}
|
|
2285
|
+
)
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
private func uniffiCallbackInitGovernanceProvider() {
|
|
2289
|
+
uniffi_native_agent_ffi_fn_init_callback_vtable_governanceprovider(&UniffiCallbackInterfaceGovernanceProvider.vtable)
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
// FfiConverter protocol for callback interfaces
|
|
2293
|
+
#if swift(>=5.8)
|
|
2294
|
+
@_documentation(visibility: private)
|
|
2295
|
+
#endif
|
|
2296
|
+
fileprivate struct FfiConverterCallbackInterfaceGovernanceProvider {
|
|
2297
|
+
fileprivate static var handleMap = UniffiHandleMap<GovernanceProvider>()
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
#if swift(>=5.8)
|
|
2301
|
+
@_documentation(visibility: private)
|
|
2302
|
+
#endif
|
|
2303
|
+
extension FfiConverterCallbackInterfaceGovernanceProvider : FfiConverter {
|
|
2304
|
+
typealias SwiftType = GovernanceProvider
|
|
2305
|
+
typealias FfiType = UInt64
|
|
2306
|
+
|
|
2307
|
+
#if swift(>=5.8)
|
|
2308
|
+
@_documentation(visibility: private)
|
|
2309
|
+
#endif
|
|
2310
|
+
public static func lift(_ handle: UInt64) throws -> SwiftType {
|
|
2311
|
+
try handleMap.get(handle: handle)
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
#if swift(>=5.8)
|
|
2315
|
+
@_documentation(visibility: private)
|
|
2316
|
+
#endif
|
|
2317
|
+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
2318
|
+
let handle: UInt64 = try readInt(&buf)
|
|
2319
|
+
return try lift(handle)
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
#if swift(>=5.8)
|
|
2323
|
+
@_documentation(visibility: private)
|
|
2324
|
+
#endif
|
|
2325
|
+
public static func lower(_ v: SwiftType) -> UInt64 {
|
|
2326
|
+
return handleMap.insert(obj: v)
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
#if swift(>=5.8)
|
|
2330
|
+
@_documentation(visibility: private)
|
|
2331
|
+
#endif
|
|
2332
|
+
public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
|
|
2333
|
+
writeInt(&buf, lower(v))
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2005
2340
|
/**
|
|
2006
2341
|
* Callback interface for memory operations (LanceDB or any vector store).
|
|
2007
2342
|
* Implemented by Kotlin/Swift, which bridges to the actual memory backend.
|
|
@@ -2020,13 +2355,7 @@ public protocol MemoryProvider : AnyObject {
|
|
|
2020
2355
|
|
|
2021
2356
|
}
|
|
2022
2357
|
|
|
2023
|
-
|
|
2024
|
-
// to free the callback once it's dropped by Rust.
|
|
2025
|
-
private let IDX_CALLBACK_FREE: Int32 = 0
|
|
2026
|
-
// Callback return codes
|
|
2027
|
-
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
|
|
2028
|
-
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
|
|
2029
|
-
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
|
|
2358
|
+
|
|
2030
2359
|
|
|
2031
2360
|
// Put the implementation in a struct so we don't pollute the top-level namespace
|
|
2032
2361
|
fileprivate struct UniffiCallbackInterfaceMemoryProvider {
|
|
@@ -2657,6 +2986,9 @@ private var initializationResult: InitializationResult = {
|
|
|
2657
2986
|
if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_event_callback() != 56165) {
|
|
2658
2987
|
return InitializationResult.apiChecksumMismatch
|
|
2659
2988
|
}
|
|
2989
|
+
if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_governance_provider() != 45093) {
|
|
2990
|
+
return InitializationResult.apiChecksumMismatch
|
|
2991
|
+
}
|
|
2660
2992
|
if (uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_heartbeat_config() != 33968) {
|
|
2661
2993
|
return InitializationResult.apiChecksumMismatch
|
|
2662
2994
|
}
|
|
@@ -2690,6 +3022,24 @@ private var initializationResult: InitializationResult = {
|
|
|
2690
3022
|
if (uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new() != 18383) {
|
|
2691
3023
|
return InitializationResult.apiChecksumMismatch
|
|
2692
3024
|
}
|
|
3025
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_check_loop() != 64194) {
|
|
3026
|
+
return InitializationResult.apiChecksumMismatch
|
|
3027
|
+
}
|
|
3028
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_record_outcome() != 15801) {
|
|
3029
|
+
return InitializationResult.apiChecksumMismatch
|
|
3030
|
+
}
|
|
3031
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_record_audit() != 34049) {
|
|
3032
|
+
return InitializationResult.apiChecksumMismatch
|
|
3033
|
+
}
|
|
3034
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_check_sink() != 37338) {
|
|
3035
|
+
return InitializationResult.apiChecksumMismatch
|
|
3036
|
+
}
|
|
3037
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_reset() != 57214) {
|
|
3038
|
+
return InitializationResult.apiChecksumMismatch
|
|
3039
|
+
}
|
|
3040
|
+
if (uniffi_native_agent_ffi_checksum_method_governanceprovider_record_usage() != 907) {
|
|
3041
|
+
return InitializationResult.apiChecksumMismatch
|
|
3042
|
+
}
|
|
2693
3043
|
if (uniffi_native_agent_ffi_checksum_method_memoryprovider_store() != 49136) {
|
|
2694
3044
|
return InitializationResult.apiChecksumMismatch
|
|
2695
3045
|
}
|
|
@@ -2712,6 +3062,7 @@ private var initializationResult: InitializationResult = {
|
|
|
2712
3062
|
return InitializationResult.apiChecksumMismatch
|
|
2713
3063
|
}
|
|
2714
3064
|
|
|
3065
|
+
uniffiCallbackInitGovernanceProvider()
|
|
2715
3066
|
uniffiCallbackInitMemoryProvider()
|
|
2716
3067
|
uniffiCallbackInitNativeEventCallback()
|
|
2717
3068
|
uniffiCallbackInitNativeNotifier()
|