You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Results are cached after the first call, just like the default behavior. The handler completely replaces the CLI's `models.list` RPC — no fallback to the server occurs.
> **Tip:** Every hook handler receives an `invocation` parameter containing the `sessionId`, which is useful for correlating logs and maintaining per-session state.
199
226
200
227
---
@@ -380,6 +407,32 @@ var session = await client.CreateSessionAsync(new SessionConfig
380
407
381
408
</details>
382
409
410
+
<details>
411
+
<summary><strong>Java</strong></summary>
412
+
413
+
```java
414
+
var readOnlyTools =Set.of("read_file", "glob", "grep", "view");
415
+
416
+
var hooks =newSessionHooks()
417
+
.setOnPreToolUse((input, invocation) -> {
418
+
if (!readOnlyTools.contains(input.getToolName())) {
419
+
returnCompletableFuture.completedFuture(
420
+
PreToolUseHookOutput.deny(
421
+
"Only read-only tools are allowed. \""+ input.getToolName() +"\" was blocked.")
When you already have image data in memory (e.g., a screenshot captured by your app, or an image fetched from an API), use a blob attachment to send it directly without writing to disk.
var base64ImageData ="..."; // your base64-encoded image
449
+
session.send(newMessageOptions()
450
+
.setPrompt("Describe what you see in this image")
451
+
.setAttachments(List.of(
452
+
newBlobAttachment()
453
+
.setData(base64ImageData)
454
+
.setMimeType("image/png")
455
+
.setDisplayName("screenshot.png")
456
+
))
457
+
).get();
458
+
}
459
+
```
460
+
461
+
</details>
462
+
403
463
## Supported Formats
404
464
405
465
Supported image formats include JPG, PNG, GIF, and other common image types. For file attachments, the runtime reads the image from disk and converts it as needed. For blob attachments, you provide the base64 data and MIME type directly. Use PNG or JPEG for best results, as these are the most widely supported formats.
Copy file name to clipboardExpand all lines: docs/features/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Features
2
2
3
-
These guides cover the capabilities you can add to your Copilot SDK application. Each guide includes examples in all supported languages (TypeScript, Python, Go, and .NET).
3
+
These guides cover the capabilities you can add to your Copilot SDK application. Each guide includes examples in all supported languages (TypeScript, Python, Go, .NET, and Java).
4
4
5
5
> **New to the SDK?** Start with the [Getting Started tutorial](../getting-started.md) first, then come back here to add more capabilities.
0 commit comments