forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreToolUseHookOutput.java
More file actions
84 lines (76 loc) · 3.09 KB
/
PreToolUseHookOutput.java
File metadata and controls
84 lines (76 loc) · 3.09 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
/**
* Output for a pre-tool-use hook.
*
* @param permissionDecision
* "allow", "deny", or "ask"
* @param permissionDecisionReason
* the reason for the permission decision
* @param modifiedArgs
* the modified tool arguments, or {@code null} to use original
* @param additionalContext
* additional context to provide to the model
* @param suppressOutput
* {@code true} to suppress output
* @since 1.0.6
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public record PreToolUseHookOutput(@JsonProperty("permissionDecision") String permissionDecision,
@JsonProperty("permissionDecisionReason") String permissionDecisionReason,
@JsonProperty("modifiedArgs") JsonNode modifiedArgs,
@JsonProperty("additionalContext") String additionalContext,
@JsonProperty("suppressOutput") Boolean suppressOutput) {
/**
* Creates an output that allows the tool to execute.
*
* @return a new PreToolUseHookOutput with permission decision "allow"
*/
public static PreToolUseHookOutput allow() {
return new PreToolUseHookOutput("allow", null, null, null, null);
}
/**
* Creates an output that denies the tool execution.
*
* @return a new PreToolUseHookOutput with permission decision "deny"
*/
public static PreToolUseHookOutput deny() {
return new PreToolUseHookOutput("deny", null, null, null, null);
}
/**
* Creates an output that denies the tool execution with a reason.
*
* @param reason
* the reason for denying the tool execution
* @return a new PreToolUseHookOutput with permission decision "deny" and reason
*/
public static PreToolUseHookOutput deny(String reason) {
return new PreToolUseHookOutput("deny", reason, null, null, null);
}
/**
* Creates an output that asks for user confirmation before executing the tool.
*
* @return a new PreToolUseHookOutput with permission decision "ask"
*/
public static PreToolUseHookOutput ask() {
return new PreToolUseHookOutput("ask", null, null, null, null);
}
/**
* Creates an output with modified tool arguments.
*
* @param permissionDecision
* "allow", "deny", or "ask"
* @param modifiedArgs
* the modified tool arguments
* @return a new PreToolUseHookOutput with the specified permission and modified
* arguments
*/
public static PreToolUseHookOutput withModifiedArgs(String permissionDecision, JsonNode modifiedArgs) {
return new PreToolUseHookOutput(permissionDecision, null, modifiedArgs, null, null);
}
}