luaskills 0.4.2

LuaSkills core runtime library for loading, invoking, and managing Lua skill packages.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
use std::ffi::{c_char, c_void};

/// Plain C ABI engine pool config used by standard non-JSON FFI calls.
/// 标准非 JSON FFI 调用使用的原生 C ABI 引擎池配置。
#[repr(C)]
pub struct FfiLuaVmPoolConfig {
    /// Minimum number of warm Lua VMs kept by the pool.
    /// 池内保持预热的最小 Lua VM 数量。
    pub min_size: usize,
    /// Maximum number of Lua VMs allowed in the pool.
    /// 池内允许存在的最大 Lua VM 数量。
    pub max_size: usize,
    /// Idle TTL in seconds applied to surplus Lua VMs.
    /// 应用于多余 Lua VM 的空闲过期秒数。
    pub idle_ttl_secs: u64,
}

/// Plain C ABI tool-cache config used by standard non-JSON FFI calls.
/// 标准非 JSON FFI 调用使用的原生 C ABI 工具缓存配置。
#[repr(C)]
pub struct FfiToolCacheConfig {
    /// Maximum number of shared tool-cache entries.
    /// 共享工具缓存允许存在的最大条目数。
    pub max_entries: usize,
    /// Default TTL in seconds applied when callers omit TTL.
    /// 当调用方省略 TTL 时应用的默认秒数。
    pub default_ttl_secs: u64,
    /// Maximum TTL in seconds accepted by the cache.
    /// 缓存允许接受的最大 TTL 秒数。
    pub max_ttl_secs: u64,
}

/// Borrowed byte-buffer view used by the refactored FFI callback surface.
/// 重构后 FFI 回调接口面使用的借用字节缓冲视图。
#[repr(C)]
pub struct FfiBorrowedBuffer {
    /// Borrowed pointer valid only for the duration of the current callback.
    /// 仅在当前回调执行期间有效的借用指针。
    pub ptr: *const u8,
    /// Number of readable bytes starting at `ptr`.
    /// 从 `ptr` 开始可读的字节数。
    pub len: usize,
}

/// Owned byte-buffer container transferred across the FFI boundary.
/// 跨 FFI 边界传递的拥有型字节缓冲容器。
#[repr(C)]
pub struct FfiOwnedBuffer {
    /// Owned heap pointer allocated by `luaskills` helper functions.
    /// 由 `luaskills` 辅助函数分配的拥有型堆指针。
    pub ptr: *mut u8,
    /// Number of owned bytes starting at `ptr`.
    /// 从 `ptr` 开始拥有的字节数。
    pub len: usize,
}

/// Plain C ABI host options used by standard non-JSON engine creation.
/// 标准非 JSON 引擎创建使用的原生 C ABI 宿主选项。
#[repr(C)]
pub struct FfiLuaRuntimeHostOptions {
    /// Optional temporary directory path.
    /// 可选临时目录路径。
    pub temp_dir: *const c_char,
    /// Optional resources directory path.
    /// 可选资源目录路径。
    pub resources_dir: *const c_char,
    /// Optional lua_packages directory path.
    /// 可选 lua_packages 目录路径。
    pub lua_packages_dir: *const c_char,
    /// Optional host-provided tools root path.
    /// 可选宿主提供工具根目录路径。
    pub host_provided_tool_root: *const c_char,
    /// Optional host-provided Lua packages root path.
    /// 可选宿主提供 Lua 包根目录路径。
    pub host_provided_lua_root: *const c_char,
    /// Optional host-provided FFI root path.
    /// 可选宿主提供 FFI 根目录路径。
    pub host_provided_ffi_root: *const c_char,
    /// Optional fixed host-owned `system_lua_lib` directory path.
    /// 可选固定宿主自有 `system_lua_lib` 目录路径。
    pub system_lua_lib_dir: *const c_char,
    /// Optional download-cache root path.
    /// 可选下载缓存根目录路径。
    pub download_cache_root: *const c_char,
    /// Required dependency sibling directory name.
    /// 必填的依赖兄弟目录名称。
    pub dependency_dir_name: *const c_char,
    /// Required state sibling directory name.
    /// 必填的状态兄弟目录名称。
    pub state_dir_name: *const c_char,
    /// Required database sibling directory name.
    /// 必填的数据库兄弟目录名称。
    pub database_dir_name: *const c_char,
    /// Optional unified skill config file path owned by the host.
    /// 由宿主拥有的可选统一技能配置文件路径。
    pub skill_config_file_path: *const c_char,
    /// Whether the runtime may perform network downloads.
    /// 运行时是否允许执行网络下载。
    pub allow_network_download: u8,
    /// Optional GitHub site base URL.
    /// 可选 GitHub 站点基址。
    pub github_base_url: *const c_char,
    /// Optional GitHub API base URL.
    /// 可选 GitHub API 基址。
    pub github_api_base_url: *const c_char,
    /// Optional host SQLite dynamic library path.
    /// 可选宿主 SQLite 动态库路径。
    pub sqlite_library_path: *const c_char,
    /// SQLite provider mode integer where `0=dynamic_library`, `1=host_callback`, and `2=space_controller`.
    /// SQLite provider 模式整数,其中 `0=dynamic_library`、`1=host_callback`、`2=space_controller`。
    pub sqlite_provider_mode: i32,
    /// SQLite callback mode integer where `0=standard` and `1=json`.
    /// SQLite 回调模式整数,其中 `0=standard`、`1=json`。
    pub sqlite_callback_mode: i32,
    /// Optional host LanceDB dynamic library path.
    /// 可选宿主 LanceDB 动态库路径。
    pub lancedb_library_path: *const c_char,
    /// LanceDB provider mode integer where `0=dynamic_library` and `1=host_callback` and `2=space_controller`.
    /// LanceDB provider 模式整数,其中 `0=dynamic_library`、`1=host_callback`、`2=space_controller`。
    pub lancedb_provider_mode: i32,
    /// LanceDB callback mode integer where `0=standard` and `1=json`.
    /// LanceDB 回调模式整数,其中 `0=standard`、`1=json`。
    pub lancedb_callback_mode: i32,
    /// Optional shared space-controller endpoint.
    /// 可选共享空间控制器端点。
    pub space_controller_endpoint: *const c_char,
    /// Whether the runtime may auto-spawn the space-controller process.
    /// 运行时是否允许自动唤起空间控制器进程。
    pub space_controller_auto_spawn: u8,
    /// Optional copied local controller executable path.
    /// 可选的本地复制控制器可执行文件路径。
    pub space_controller_executable_path: *const c_char,
    /// Space-controller process mode integer where `0=service` and `1=managed`.
    /// 空间控制器进程模式整数,其中 `0=service`、`1=managed`。
    pub space_controller_process_mode: i32,
    /// Optional tool-cache config pointer.
    /// 可选工具缓存配置指针。
    pub cache_config: *const FfiToolCacheConfig,
    /// Optional dedicated isolated runlua VM pool config.
    /// 可选的隔离 runlua 虚拟机独立池配置。
    pub runlua_pool_config: *const FfiLuaVmPoolConfig,
    /// Reserved public entry names.
    /// 保留公开入口名称数组。
    pub reserved_entry_names: *const *const c_char,
    /// Number of reserved public entry names.
    /// 保留公开入口名称数组长度。
    pub reserved_entry_names_len: usize,
    /// Host-forced ignored skill identifiers.
    /// 宿主强制忽略的技能标识符数组。
    pub ignored_skill_ids: *const *const c_char,
    /// Number of host-forced ignored skill identifiers.
    /// 宿主强制忽略的技能标识符数组长度。
    pub ignored_skill_ids_len: usize,
    /// Whether Lua may use `vulcan.runtime.skills.*` management bridges.
    /// Lua 是否允许使用 `vulcan.runtime.skills.*` 管理桥接。
    pub enable_skill_management_bridge: u8,
    /// Optional default text encoding label for managed IO and process APIs.
    /// 托管 IO 与进程 API 使用的可选默认文本编码标签。
    pub default_text_encoding: *const c_char,
    /// Whether luaexec and runtime sessions must keep Lua's native `io` table.
    /// luaexec 与持久运行时会话是否必须保留 Lua 原生 `io` 表。
    pub disable_managed_io_compat: u8,
}

/// C ABI JSON provider callback used by non-Rust hosts to bridge database requests.
/// 供非 Rust 宿主桥接数据库请求使用的 C ABI JSON provider 回调。
pub type FfiJsonProviderCallback = unsafe extern "C" fn(
    request_json: FfiBorrowedBuffer,
    user_data: *mut c_void,
    response_out: *mut FfiOwnedBuffer,
    error_out: *mut FfiOwnedBuffer,
) -> i32;

/// C ABI SQLite provider callback used by standard host integration.
/// 标准宿主集成使用的 C ABI SQLite provider 回调。
pub type FfiSqliteProviderCallback = unsafe extern "C" fn(
    request: *const FfiSqliteProviderRequest,
    user_data: *mut c_void,
    response_json_out: *mut FfiOwnedBuffer,
    error_out: *mut FfiOwnedBuffer,
) -> i32;

/// C ABI LanceDB provider callback used by standard host integration.
/// 标准宿主集成使用的 C ABI LanceDB provider 回调。
pub type FfiLanceDbProviderCallback = unsafe extern "C" fn(
    request: *const FfiLanceDbProviderRequest,
    user_data: *mut c_void,
    meta_json_out: *mut FfiOwnedBuffer,
    data_out: *mut FfiOwnedBuffer,
    error_out: *mut FfiOwnedBuffer,
) -> i32;

/// Plain C ABI engine options used by standard non-JSON engine creation.
/// 标准非 JSON 引擎创建使用的原生 C ABI 引擎选项。
#[repr(C)]
pub struct FfiLuaEngineOptions {
    /// Pool config applied to the runtime engine.
    /// 应用于运行时引擎的池配置。
    pub pool: FfiLuaVmPoolConfig,
    /// Host options applied to the runtime engine.
    /// 应用于运行时引擎的宿主选项。
    pub host: FfiLuaRuntimeHostOptions,
}

/// Plain C ABI skill root used by standard non-JSON lifecycle and load calls.
/// 标准非 JSON 生命周期与加载调用使用的原生 C ABI 技能根结构。
#[repr(C)]
pub struct FfiRuntimeSkillRoot {
    /// Stable root name, limited to ROOT, PROJECT, or USER.
    /// 稳定根名称,仅限 ROOT、PROJECT 或 USER。
    pub name: *const c_char,
    /// Physical skills directory path.
    /// 物理 skills 目录路径。
    pub skills_dir: *const c_char,
}

/// Plain C ABI invocation context used by standard non-JSON call paths.
/// 标准非 JSON 调用路径使用的原生 C ABI 调用上下文。
#[repr(C)]
pub struct FfiLuaInvocationContext {
    /// Optional request context encoded as one borrowed JSON byte buffer.
    /// 以借用 JSON 字节缓冲编码的可选请求上下文。
    pub request_context_json: FfiBorrowedBuffer,
    /// Optional client budget encoded as one borrowed JSON byte buffer.
    /// 以借用 JSON 字节缓冲编码的可选客户端预算。
    pub client_budget_json: FfiBorrowedBuffer,
    /// Optional tool config encoded as one borrowed JSON byte buffer.
    /// 以借用 JSON 字节缓冲编码的可选工具配置。
    pub tool_config_json: FfiBorrowedBuffer,
}

/// Plain C ABI managed install request used by standard lifecycle calls.
/// 标准生命周期调用使用的原生 C ABI 受管安装请求。
#[repr(C)]
pub struct FfiSkillInstallRequest {
    /// Optional target skill id.
    /// 可选目标技能标识符。
    pub skill_id: *const c_char,
    /// Optional source locator.
    /// 可选来源定位值。
    pub source: *const c_char,
    /// Managed source type encoded as one integer.
    /// 以整数编码的受管来源类型。
    pub source_type: i32,
}

/// Plain C ABI uninstall options used by standard lifecycle calls.
/// 标准生命周期调用使用的原生 C ABI 卸载选项。
#[repr(C)]
pub struct FfiSkillUninstallOptions {
    /// Remove SQLite data when non-zero.
    /// 非零时删除 SQLite 数据。
    pub remove_sqlite: u8,
    /// Remove LanceDB data when non-zero.
    /// 非零时删除 LanceDB 数据。
    pub remove_lancedb: u8,
}

/// Plain C ABI database binding context forwarded into one host-managed database provider.
/// 转发给宿主管理数据库 provider 的原生 C ABI 数据库绑定上下文。
#[repr(C)]
pub struct FfiRuntimeDatabaseBindingContext {
    /// Stable host-provided space label such as ROOT, PROJECT, or USER.
    /// 由宿主提供的稳定空间标签,例如 ROOT、PROJECT 或 USER。
    pub space_label: *const c_char,
    /// Stable skill identifier owning the current binding.
    /// 拥有当前绑定的稳定技能标识符。
    pub skill_id: *const c_char,
    /// Stable database binding tag composed from space label and skill id.
    /// 由空间标签与技能标识符组合得到的稳定数据库绑定标签。
    pub binding_tag: *const c_char,
    /// Effective physical skill root label that resolved the current skill instance.
    /// 解析出当前技能实例的生效物理技能根标签。
    pub root_name: *const c_char,
    /// Physical space root directory path.
    /// 物理空间根目录路径。
    pub space_root: *const c_char,
    /// Physical skill directory path.
    /// 物理技能目录路径。
    pub skill_dir: *const c_char,
    /// Basename of the physical skill directory.
    /// 物理技能目录名称。
    pub skill_dir_name: *const c_char,
    /// Database kind integer where `0=sqlite` and `1=lancedb`.
    /// 数据库类型整数,其中 `0=sqlite`、`1=lancedb`。
    pub database_kind: i32,
    /// Library-computed default embedded database path for diagnostics and fallback.
    /// 由库计算出的默认内嵌数据库路径,用于诊断和回退。
    pub default_database_path: *const c_char,
}

/// Plain C ABI SQLite provider request delivered to one host callback.
/// 传递给宿主回调的原生 C ABI SQLite provider 请求。
#[repr(C)]
pub struct FfiSqliteProviderRequest {
    /// Requested action integer defined by `FFI_SQLITE_PROVIDER_ACTION_*`.
    /// 由 `FFI_SQLITE_PROVIDER_ACTION_*` 定义的请求动作整数。
    pub action: i32,
    /// Stable binding context of the current skill-scoped database.
    /// 当前 skill 级数据库的稳定绑定上下文。
    pub binding: FfiRuntimeDatabaseBindingContext,
    /// Action-specific input payload encoded as one borrowed JSON byte buffer.
    /// 以借用 JSON 字节缓冲编码的动作专属输入载荷。
    pub input_json: FfiBorrowedBuffer,
}

/// Plain C ABI LanceDB provider request delivered to one host callback.
/// 传递给宿主回调的原生 C ABI LanceDB provider 请求。
#[repr(C)]
pub struct FfiLanceDbProviderRequest {
    /// Requested action integer defined by `FFI_LANCEDB_PROVIDER_ACTION_*`.
    /// 由 `FFI_LANCEDB_PROVIDER_ACTION_*` 定义的请求动作整数。
    pub action: i32,
    /// Stable binding context of the current skill-scoped database.
    /// 当前 skill 级数据库的稳定绑定上下文。
    pub binding: FfiRuntimeDatabaseBindingContext,
    /// Action-specific input payload encoded as one borrowed JSON byte buffer.
    /// 以借用 JSON 字节缓冲编码的动作专属输入载荷。
    pub input_json: FfiBorrowedBuffer,
}

/// Plain C ABI string-array result.
/// 原生 C ABI 字符串数组结果。
#[repr(C)]
pub struct FfiStringArray {
    /// Owned UTF-8 string buffers.
    /// 拥有所有权的 UTF-8 字符串缓冲数组。
    pub items: *mut FfiOwnedBuffer,
    /// Number of string items.
    /// 字符串条目数量。
    pub len: usize,
}

/// Plain C ABI entry parameter descriptor.
/// 原生 C ABI 入口参数描述结构。
#[repr(C)]
pub struct FfiRuntimeEntryParameterDescriptor {
    /// Stable parameter name.
    /// 稳定参数名。
    pub name: FfiOwnedBuffer,
    /// Runtime parameter type string.
    /// 运行时参数类型字符串。
    pub param_type: FfiOwnedBuffer,
    /// Human-readable parameter description.
    /// 人类可读参数说明。
    pub description: FfiOwnedBuffer,
    /// Whether the parameter is required.
    /// 当前参数是否必填。
    pub required: u8,
}

/// Plain C ABI entry descriptor.
/// 原生 C ABI 入口描述结构。
#[repr(C)]
pub struct FfiRuntimeEntryDescriptor {
    /// Canonical runtime entry name.
    /// canonical 运行时入口名称。
    pub canonical_name: FfiOwnedBuffer,
    /// Owning skill id.
    /// 所属技能标识符。
    pub skill_id: FfiOwnedBuffer,
    /// Local entry name declared by the skill.
    /// 技能声明的局部入口名。
    pub local_name: FfiOwnedBuffer,
    /// Effective root name.
    /// 生效根名称。
    pub root_name: FfiOwnedBuffer,
    /// Effective physical skill directory.
    /// 生效物理技能目录。
    pub skill_dir: FfiOwnedBuffer,
    /// Human-readable entry description.
    /// 人类可读入口描述。
    pub description: FfiOwnedBuffer,
    /// Parameter descriptor array.
    /// 参数描述数组。
    pub parameters: *mut FfiRuntimeEntryParameterDescriptor,
    /// Parameter descriptor count.
    /// 参数描述数量。
    pub parameters_len: usize,
}

/// Plain C ABI entry descriptor list.
/// 原生 C ABI 入口描述列表。
#[repr(C)]
pub struct FfiRuntimeEntryDescriptorList {
    /// Entry descriptor items.
    /// 入口描述条目。
    pub items: *mut FfiRuntimeEntryDescriptor,
    /// Entry descriptor count.
    /// 入口描述数量。
    pub len: usize,
}

/// Plain C ABI help node descriptor.
/// 原生 C ABI 帮助节点描述结构。
#[repr(C)]
pub struct FfiRuntimeHelpNodeDescriptor {
    /// Help flow name.
    /// 帮助流程名。
    pub flow_name: FfiOwnedBuffer,
    /// Human-readable node description.
    /// 人类可读节点描述。
    pub description: FfiOwnedBuffer,
    /// Related canonical runtime entry names.
    /// 关联的 canonical 运行时入口名称。
    pub related_entries: *mut FfiOwnedBuffer,
    /// Number of related canonical runtime entry names.
    /// 关联 canonical 运行时入口名称数量。
    pub related_entries_len: usize,
    /// Whether the node is the main help node.
    /// 当前节点是否为主帮助节点。
    pub is_main: u8,
}

/// Plain C ABI help tree descriptor.
/// 原生 C ABI 帮助树描述结构。
#[repr(C)]
pub struct FfiRuntimeSkillHelpDescriptor {
    /// Stable skill id.
    /// 稳定技能标识符。
    pub skill_id: FfiOwnedBuffer,
    /// Human-readable skill name.
    /// 人类可读技能名称。
    pub skill_name: FfiOwnedBuffer,
    /// Semantic skill version.
    /// 语义化技能版本。
    pub skill_version: FfiOwnedBuffer,
    /// Effective root name.
    /// 生效根名称。
    pub root_name: FfiOwnedBuffer,
    /// Effective physical skill directory.
    /// 生效物理技能目录。
    pub skill_dir: FfiOwnedBuffer,
    /// Main help node descriptor.
    /// 主帮助节点描述。
    pub main: FfiRuntimeHelpNodeDescriptor,
    /// Flow help node descriptor array.
    /// 流程帮助节点描述数组。
    pub flows: *mut FfiRuntimeHelpNodeDescriptor,
    /// Flow help node descriptor count.
    /// 流程帮助节点描述数量。
    pub flows_len: usize,
}

/// Plain C ABI help tree descriptor list.
/// 原生 C ABI 帮助树描述列表。
#[repr(C)]
pub struct FfiRuntimeSkillHelpDescriptorList {
    /// Help descriptor items.
    /// 帮助描述条目。
    pub items: *mut FfiRuntimeSkillHelpDescriptor,
    /// Help descriptor count.
    /// 帮助描述数量。
    pub len: usize,
}

/// Plain C ABI help detail descriptor.
/// 原生 C ABI 帮助详情描述结构。
#[repr(C)]
pub struct FfiRuntimeHelpDetail {
    /// Stable skill id.
    /// 稳定技能标识符。
    pub skill_id: FfiOwnedBuffer,
    /// Human-readable skill name.
    /// 人类可读技能名称。
    pub skill_name: FfiOwnedBuffer,
    /// Semantic skill version.
    /// 语义化技能版本。
    pub skill_version: FfiOwnedBuffer,
    /// Effective root name.
    /// 生效根名称。
    pub root_name: FfiOwnedBuffer,
    /// Effective physical skill directory.
    /// 生效物理技能目录。
    pub skill_dir: FfiOwnedBuffer,
    /// Flow name.
    /// 流程名称。
    pub flow_name: FfiOwnedBuffer,
    /// Human-readable description.
    /// 人类可读描述。
    pub description: FfiOwnedBuffer,
    /// Related canonical runtime entries.
    /// 关联的 canonical 运行时入口。
    pub related_entries: *mut FfiOwnedBuffer,
    /// Number of related canonical runtime entries.
    /// 关联 canonical 运行时入口数量。
    pub related_entries_len: usize,
    /// Whether the node is the main help node.
    /// 当前节点是否为主帮助节点。
    pub is_main: u8,
    /// Structured content type.
    /// 结构化内容类型。
    pub content_type: FfiOwnedBuffer,
    /// Final rendered help content.
    /// 最终渲染出的帮助内容。
    pub content: FfiOwnedBuffer,
}

/// Plain C ABI invocation result.
/// 原生 C ABI 调用结果结构。
#[repr(C)]
pub struct FfiRuntimeHostResult {
    /// Stable host-result kind.
    /// 稳定宿主结果类型。
    pub kind: FfiOwnedBuffer,
    /// Serialized host-result payload JSON.
    /// 序列化后的宿主结果载荷 JSON。
    pub payload_json: FfiOwnedBuffer,
    /// Serialized host-result payload byte size.
    /// 序列化后宿主结果载荷字节数。
    pub payload_bytes: usize,
}

/// Plain C ABI invocation result.
/// 原生 C ABI 调用结果结构。
#[repr(C)]
pub struct FfiRuntimeInvocationResult {
    /// Tool body content.
    /// 工具正文内容。
    pub content: FfiOwnedBuffer,
    /// Overflow mode encoded as 0 none, 1 truncate, 2 page.
    /// 以 0 无、1 截断、2 分页编码的超限模式。
    pub overflow_mode: i32,
    /// Optional template hint.
    /// 可选模板提示名。
    pub template_hint: FfiOwnedBuffer,
    /// Content byte count.
    /// 内容字节数。
    pub content_bytes: usize,
    /// Content line count.
    /// 内容行数。
    pub content_lines: usize,
    /// Optional structured host-side result pointer.
    /// 可选结构化宿主结果指针。
    pub host_result: *mut FfiRuntimeHostResult,
}

/// Plain C ABI install or update result.
/// 原生 C ABI 安装或更新结果结构。
#[repr(C)]
pub struct FfiSkillApplyResult {
    /// Stable skill id.
    /// 稳定技能标识符。
    pub skill_id: FfiOwnedBuffer,
    /// High-level result status.
    /// 高层结果状态。
    pub status: FfiOwnedBuffer,
    /// Human-readable message.
    /// 人类可读消息。
    pub message: FfiOwnedBuffer,
    /// Optional semantic version.
    /// 可选语义化版本。
    pub version: FfiOwnedBuffer,
    /// Optional source type encoded as integer, where -1 means absent.
    /// 以整数编码的可选来源类型,-1 表示不存在。
    pub source_type: i32,
    /// Optional source locator.
    /// 可选来源定位值。
    pub source_locator: FfiOwnedBuffer,
}

/// Plain C ABI uninstall result.
/// 原生 C ABI 卸载结果结构。
#[repr(C)]
pub struct FfiSkillUninstallResult {
    /// Stable skill id.
    /// 稳定技能标识符。
    pub skill_id: FfiOwnedBuffer,
    /// Whether the skill directory was removed.
    /// 技能目录是否已被删除。
    pub skill_removed: u8,
    /// Whether the SQLite database was removed.
    /// SQLite 数据库是否已被删除。
    pub sqlite_removed: u8,
    /// Whether the LanceDB database was removed.
    /// LanceDB 数据库是否已被删除。
    pub lancedb_removed: u8,
    /// Whether the SQLite database was intentionally retained.
    /// SQLite 数据库是否被有意保留。
    pub sqlite_retained: u8,
    /// Whether the LanceDB database was intentionally retained.
    /// LanceDB 数据库是否被有意保留。
    pub lancedb_retained: u8,
    /// Human-readable message.
    /// 人类可读消息。
    pub message: FfiOwnedBuffer,
}