Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"java.autobuild.enabled": false,
Comment thread
edburns marked this conversation as resolved.
"java.configuration.updateBuildConfiguration": "automatic",
"java.compile.nullAnalysis.mode": "automatic"
}
6 changes: 6 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
require npm or network access.
-->
<skip.cli.install>${skip.test.harness}</skip.cli.install>
<!-- Override with -Dnpm.loglevel=verbose when troubleshooting npm. -->
<npm.loglevel>notice</npm.loglevel>
<!-- Extra JVM args for Surefire; overridden by the jdk21+ profile -->
<surefire.jvm.args />
<!--
Expand Down Expand Up @@ -213,6 +215,8 @@
<workingDirectory>${copilot.sdk.root}/test/harness</workingDirectory>
<arguments>
<argument>ci</argument>
<argument>--loglevel</argument>
<argument>${npm.loglevel}</argument>
</arguments>
</configuration>
</execution>
Expand All @@ -235,6 +239,8 @@
<arguments>
<argument>ci</argument>
<argument>--ignore-scripts</argument>
<argument>--loglevel</argument>
<argument>${npm.loglevel}</argument>
</arguments>
</configuration>
</execution>
Expand Down
17 changes: 16 additions & 1 deletion java/src/main/java/com/github/copilot/rpc/ParamSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.copilot.tool.Param;

Expand Down Expand Up @@ -84,7 +85,21 @@ static Map<String, Object> buildSchema(String toolName, ObjectMapper mapper, Par
Map<String, Object> properties = new LinkedHashMap<>();

for (Param<?> param : params) {
Map<String, Object> typeSchema = forType(param.type());
Map<String, Object> typeSchema;
if (!param.schema().isEmpty()) {
try {
@SuppressWarnings("unchecked")
Map<String, Object> parsed = mapper.readerFor(Map.class)
.with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
.with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS).readValue(param.schema());
typeSchema = parsed;
} catch (Exception e) {
throw new IllegalArgumentException("Invalid schema JSON for parameter '" + param.name()
+ "' in tool '" + toolName + "': " + e.getMessage(), e);
}
} else {
typeSchema = forType(param.type());
}
Map<String, Object> enriched = new LinkedHashMap<>(typeSchema);
enriched.put("description", param.description());
if (param.hasDefaultValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,22 @@

/** Optional default value when the argument is omitted. */
String defaultValue() default "";

/**
* Optional explicit JSON Schema for this parameter as a JSON string literal.
* When non-empty, bypasses automatic schema generation from the parameter type.
* The value must be a valid JSON object string.
*
* <p>
* Example:
*
* <pre>
* &#64;CopilotTool("Schedule meeting")
* public String schedule(
* &#64;CopilotToolParam(value = "When to meet", schema = "{\"type\":\"string\",\"format\":\"date-time\"}") MyCustomDateTime when) {
* // ...
* }
* </pre>
*/
String schema() default "";
}
Loading
Loading