Skip to content

Commit 469a37f

Browse files
committed
chore: update dependency versions and improve error handling in example and Swift files
1 parent 9fe49ea commit 469a37f

File tree

9 files changed

+28
-27
lines changed

9 files changed

+28
-27
lines changed

.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(./build.sh)"
5+
],
6+
"deny": []
7+
}
8+
}

build/AppleOnDeviceAI.swiftdoc

-4 Bytes
Binary file not shown.

build/AppleOnDeviceAI.swiftmodule

192 Bytes
Binary file not shown.
-4 Bytes
Binary file not shown.

build/libappleai.dylib

784 Bytes
Binary file not shown.

bun.lock

Lines changed: 7 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/18-weather.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ async function main() {
464464
messages.push({ role: "tool", content: toolResponses });
465465
}
466466
} catch (_error) {
467-
spinner.fail(chalk.red("Error occurred"));
467+
spinner.fail(chalk.red("Error occurred", _error));
468468
console.log("");
469469
}
470470
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@
7979
"arm64"
8080
],
8181
"dependencies": {
82-
"@ai-sdk/provider": "2.0.0-beta.1",
83-
"@ai-sdk/provider-utils": "3.0.0-beta.2",
82+
"@ai-sdk/provider": "^2.0.0-beta.1",
83+
"@ai-sdk/provider-utils": "^3.0.0-beta.5",
8484
"@types/json-schema": "^7.0.15",
85+
"ai": "^5.0.0-beta.25",
8586
"h3": "^1.15.3",
8687
"json-schema": "^0.4.0",
87-
"zod-to-json-schema": "^3.24.5",
88-
"ai": "5.0.0-beta.9"
88+
"zod-to-json-schema": "^3.24.5"
8989
},
9090
"peerDependencies": {
9191
"ai": "",

src/apple-ai.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,10 @@ private func emitError(
682682
// MARK: - JS Tool Callback Bridge
683683

684684
// Simple async callback - Rust calls this, expects result via separate callback
685-
public typealias JSToolCallback = @convention(c) (
686-
_ toolID: UInt64, _ argsJson: UnsafePointer<CChar>
687-
) -> Void
685+
public typealias JSToolCallback =
686+
@convention(c) (
687+
_ toolID: UInt64, _ argsJson: UnsafePointer<CChar>
688+
) -> Void
688689

689690
private var jsToolCallback: JSToolCallback?
690691

@@ -715,17 +716,17 @@ private struct JSProxyTool: Tool {
715716

716717
var parameters: GenerationSchema { parametersSchema }
717718

718-
func call(arguments: JSArguments) async throws -> ToolOutput {
719+
func call(arguments: JSArguments) async throws -> String {
719720
guard let cb = jsToolCallback else {
720-
return ToolOutput("Tool system not available")
721+
return "Tool system not available"
721722
}
722723

723724
// Serialize arguments and forward to JavaScript for external execution
724725
let jsonObj = generatedContentToJSON(arguments.raw)
725726
guard let data = try? JSONSerialization.data(withJSONObject: jsonObj),
726727
let jsonStr = String(data: data, encoding: .utf8)
727728
else {
728-
return ToolOutput("Unable to process tool arguments")
729+
return "Unable to process tool arguments"
729730
}
730731

731732
// Notify JavaScript side for collection and external execution
@@ -742,7 +743,7 @@ private struct JSProxyTool: Tool {
742743
await StreamingCoordinator.shared.toolCompleted()
743744

744745
// Return placeholder output to allow generation to continue naturally
745-
return ToolOutput("Tool call executed")
746+
return "Tool call executed"
746747
}
747748
}
748749

0 commit comments

Comments
 (0)