Port copilotHome, tcpConnectionToken, and instructionDirectories from reference implementation#151
Port copilotHome, tcpConnectionToken, and instructionDirectories from reference implementation#151
Conversation
… reference implementation Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
…ries Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
…tionDirectories Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
…om.xml CLI version, and update scripts/codegen @github/copilot version Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Auto-committed by codegen-check workflow.
|
@copilot Fix the 3 remaining test compilation errors. Do NOT edit any file under The errors (from the Codegen Check run):
After fixing, run |
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Fixed all 3 compilation errors in
|
There was a problem hiding this comment.
Pull request overview
Ports several configuration and protocol features from the upstream reference implementation into the Java SDK, improving CLI process configuration, TCP security, and session instruction discovery while aligning tests/docs with updated schemas.
Changes:
- Add
copilotHome(setsCOPILOT_HOME) andtcpConnectionToken(supports authenticated TCP viaconnect, with legacypingfallback). - Add
instructionDirectoriessupport to both session create and resume requests. - Update docs/tests and regenerated schema types to match the newer reference implementation version.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/github/copilot/sdk/CopilotClient.java | Adds TCP connection token validation, auto-token generation for SDK-spawned TCP, and connect-based protocol handshake with fallback to ping. |
| src/main/java/com/github/copilot/sdk/CliServerManager.java | Passes COPILOT_HOME and COPILOT_CONNECTION_TOKEN environment variables to spawned CLI process. |
| src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java | Wires instructionDirectories into session.create and session.resume request payloads. |
| src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java | Adds copilotHome and tcpConnectionToken options and cloning support. |
| src/main/java/com/github/copilot/sdk/json/SessionConfig.java | Adds instructionDirectories field, accessors, and cloning support. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java | Adds instructionDirectories field, accessors, and cloning support. |
| src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java | Adds instructionDirectories JSON property to create-session wire request. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java | Adds instructionDirectories JSON property to resume-session wire request. |
| src/test/java/com/github/copilot/sdk/CopilotClientTest.java | Adds tests for tcpConnectionToken validation and copilotHome option persistence. |
| src/test/java/com/github/copilot/sdk/ConfigCloneTest.java | Ensures new options/config fields clone correctly and list independence is preserved. |
| src/test/java/com/github/copilot/sdk/SessionEventHandlingTest.java | Updates event construction to match new generated AssistantMessageEventData signature. |
| src/test/java/com/github/copilot/sdk/SessionEventDeserializationTest.java | Adjusts permission-completed assertions after schema changed result to Object. |
| src/test/java/com/github/copilot/sdk/generated/rpc/GeneratedRpcRecordsCoverageTest.java | Updates generated RPC record coverage test for new SessionUsageGetMetricsResult fields/order. |
| src/test/java/com/github/copilot/sdk/SessionConfigE2ETest.java | Adds (currently disabled) E2E tests intended to validate instructionDirectories behavior. |
| src/site/markdown/setup.md | Documents TCP connection token usage and adds copilotHome/tcpConnectionToken to the options table. |
| src/site/markdown/advanced.md | Documents instructionDirectories usage for create/resume. |
| scripts/codegen/package.json | Bumps @github/copilot used for code generation inputs. |
| scripts/codegen/package-lock.json | Locks updated @github/copilot dependency graph. |
| pom.xml | Updates the tracked reference-implementation CLI version property. |
| .lastmerge | Updates the recorded reference-implementation commit hash. |
| src/generated/java/com/github/copilot/sdk/generated/UserMessageEvent.java | Regenerated: adds parentAgentTaskId. |
| src/generated/java/com/github/copilot/sdk/generated/ToolExecutionStartEvent.java | Regenerated: adds turnId. |
| src/generated/java/com/github/copilot/sdk/generated/ToolExecutionCompleteEvent.java | Regenerated: adds turnId. |
| src/generated/java/com/github/copilot/sdk/generated/ShutdownTokenDetail.java | Regenerated: new type for shutdown token details. |
| src/generated/java/com/github/copilot/sdk/generated/ShutdownModelMetricTokenDetail.java | Regenerated: new type for shutdown model token details. |
| src/generated/java/com/github/copilot/sdk/generated/ShutdownModelMetric.java | Regenerated: adds nano-AI units + token detail map. |
| src/generated/java/com/github/copilot/sdk/generated/SessionShutdownEvent.java | Regenerated: adds nano-AI units + token details. |
| src/generated/java/com/github/copilot/sdk/generated/SessionResumeEvent.java | Regenerated: adds sessionWasActive and continuePendingWork. |
| src/generated/java/com/github/copilot/sdk/generated/SessionEvent.java | Regenerated: registers new assistant.message_start subtype. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/UsageMetricsTokenDetail.java | Regenerated: new type for token details. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/UsageMetricsModelMetricTokenDetail.java | Regenerated: new type for per-model token details. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/UsageMetricsModelMetric.java | Regenerated: adds nano-AI units + token detail map. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/SessionUsageGetMetricsResult.java | Regenerated: adds nano-AI units + token details at session scope. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/SessionSuspendParams.java | Regenerated: new params record for session.suspend. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/SessionRpc.java | Regenerated: adds session.suspend() helper. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/ServerRpc.java | Regenerated: adds connect() helper. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/ConnectResult.java | Regenerated: new connect result schema. |
| src/generated/java/com/github/copilot/sdk/generated/rpc/ConnectParams.java | Regenerated: new connect params schema. |
| src/generated/java/com/github/copilot/sdk/generated/PermissionCompletedEvent.java | Regenerated: changes result type to Object. |
| src/generated/java/com/github/copilot/sdk/generated/McpOauthRequiredStaticClientConfig.java | Regenerated: adds optional grantType. |
| src/generated/java/com/github/copilot/sdk/generated/CompactionCompleteCompactionTokensUsedCopilotUsage.java | Regenerated: doc wording update for nano-AI units. |
| src/generated/java/com/github/copilot/sdk/generated/AssistantUsageCopilotUsage.java | Regenerated: doc wording update for nano-AI units. |
| src/generated/java/com/github/copilot/sdk/generated/AssistantMessageStartEvent.java | Regenerated: new assistant.message_start event type. |
| src/generated/java/com/github/copilot/sdk/generated/AssistantMessageEvent.java | Regenerated: adds turnId. |
Copilot's findings
Files not reviewed (1)
- scripts/codegen/package-lock.json: Language not supported
- Files reviewed: 18/44 changed files
- Comments generated: 6
| request.setSkillDirectories(config.getSkillDirectories()); | ||
| request.setInstructionDirectories(config.getInstructionDirectories()); | ||
| request.setDisabledSkills(config.getDisabledSkills()); |
| @Disabled("Requires test harness update with instructionDirectories snapshots - see reference impl PR #1190") | ||
| @Test | ||
| void testShouldApplyInstructionDirectoriesOnCreate() throws Exception { | ||
| ctx.configureForTest("session_config", "should_apply_instructiondirectories_on_create"); |
| var event = (PermissionCompletedEvent) parseJson(json); | ||
| assertNotNull(event); | ||
| assertEquals("permission.completed", event.getType()); | ||
| assertEquals("perm-req-456", event.getData().requestId()); | ||
| assertEquals(PermissionCompletedKind.APPROVED, event.getData().result().kind()); | ||
| assertNotNull(event.getData().result()); |
| try { | ||
| // Try the new 'connect' RPC which supports connection tokens | ||
| var connectParams = new HashMap<String, Object>(); | ||
| connectParams.put("token", effectiveConnectionToken); | ||
| var connectResponse = connection.rpc.invoke("connect", connectParams, ConnectResult.class).get(30, | ||
| TimeUnit.SECONDS); | ||
| serverVersion = connectResponse.protocolVersion(); |
| /** | ||
| * Sets the base directory for Copilot data (session state, config, etc.). | ||
| * <p> | ||
| * Sets the {@code COPILOT_HOME} environment variable on the spawned CLI | ||
| * process. When {@code null}, the CLI defaults to {@code ~/.copilot}. | ||
| * <p> | ||
| * This option is only used when the SDK spawns the CLI process; it is ignored | ||
| * when connecting to an external server via {@link #setCliUrl(String)}. | ||
| * | ||
| * @param copilotHome | ||
| * the Copilot home directory path (must not be {@code null}) | ||
| * @return this options instance for method chaining | ||
| */ | ||
| public CopilotClientOptions setCopilotHome(String copilotHome) { | ||
| this.copilotHome = Objects.requireNonNull(copilotHome, "copilotHome must not be null"); | ||
| return this; | ||
| } |
| PR. | ||
| --> | ||
| <readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.40-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync> | ||
| <readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.41-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync> |
edburns
left a comment
There was a problem hiding this comment.
@copilot The instructionDirectories test snapshots from github/copilot-sdk PR #1190 have been merged. Remove the @disabled annotations from both tests in SessionConfigE2ETest.java and run mvn verify to confirm they pass. The test harness in target/copilot-sdk/ may need to be refreshed first — run mvn generate-test-resources to re-clone it with the latest snapshots.
|
@copilot The |
…ange parsing Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/cad2855d-0ec3-43e1-acef-49e96848b902 Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Done in
Done in |
Resolves #350
Before the change?
copilotHomeoption for configurable Copilot data directoryinstructionDirectoriessession config for custom instruction file discoverypingRPC (noconnectwith token)PermissionCompletedKind, 11-paramAssistantMessageEventData, 9-paramSessionUsageGetMetricsResult)instructionDirectorieswere disabled pending upstream snapshot availabilityAfter the change?
copilotHome— SetsCOPILOT_HOMEenv var on spawned CLI process for custom data directorytcpConnectionToken— Auto-generates UUID for SDK-spawned TCP mode; sends token via newconnectRPC with fallback topingfor legacy serversinstructionDirectories— Forwarded in bothsession.createandsession.resumeRPC calls; E2E tests now enabled with upstream snapshots from copilot-sdk PR #1190SessionEventDeserializationTest: replaced.result().kind()withassertNotNull(result)sincePermissionCompletedEventData.result()is nowObjectSessionEventHandlingTest: added 12thnullparam for newmessageIdfield inAssistantMessageEventDataGeneratedRpcRecordsCoverageTest: addednullfor newtotalNanoAiu,tokenDetails, andmodelMetricsfields inSessionUsageGetMetricsResultSessionConfigE2ETest.getSystemMessage()to correctly navigate the exchange structure (exchange.request.messages[]instead ofexchange.messages[])Not ported (intentionally):
@github/copilotversion bumps (generated code, handled by codegen workflow)Pull request checklist
mvn spotless:applyhas been run to format the codemvn clean verifypasses locallyDoes this introduce a breaking change?