Skip to content

refactor: split SDK RPC client#339

Open
kermanx wants to merge 4 commits into
mainfrom
xtr/split-node-sdk-rpc-client
Open

refactor: split SDK RPC client#339
kermanx wants to merge 4 commits into
mainfrom
xtr/split-node-sdk-rpc-client

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented Jun 2, 2026

Related Issue

No linked issue. This change comes from maintainer discussion to make the SDK harness usable with a transport supplied by web integrations.

Problem

The SDK harness constructed its local in-memory RPC client internally, which made it hard for other runtimes to provide their own RPC transport without reworking the harness itself. CLI startup also needed to keep using the local runtime path after the constructor split.

What changed

  • Split the shared SDK RPC behavior from the local in-memory RPC client implementation.
  • Updated the harness to accept an injected RPC client plus explicit runtime dependencies.
  • Added a local harness factory and updated the CLI, tests, and SDK examples to use it.
  • Added a changeset for the SDK and CLI bundle.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification

  • pnpm exec oxlint apps/kimi-code/src/cli/run-shell.ts apps/kimi-code/src/cli/run-prompt.ts apps/kimi-code/src/cli/sub/export.ts apps/kimi-code/test/cli/run-shell.test.ts apps/kimi-code/test/cli/run-prompt.test.ts apps/kimi-code/test/cli/export.test.ts apps/kimi-code/test/e2e/real-llm-smoke.e2e.test.ts apps/kimi-code/test/e2e/local-logging-export.e2e.test.ts packages/node-sdk/examples/kimi-harness-auth-smoke.ts packages/node-sdk/examples/t8-race-create.ts packages/node-sdk/src/kimi-harness.ts packages/node-sdk/src/local-rpc.ts
  • pnpm -C packages/node-sdk run typecheck
  • pnpm -C apps/kimi-code run typecheck
  • pnpm -C apps/kimi-code exec vitest run test/cli/run-shell.test.ts test/cli/run-prompt.test.ts test/cli/export.test.ts
  • pnpm dev:cli -- migrate

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: c559277

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code-sdk Minor
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7b1ec4fff

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/node-sdk/src/kimi-harness.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c559277
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c559277

commit: c559277

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c39d31e99

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/node-sdk/src/local-rpc.ts Outdated
Comment on lines +96 to +97
userAgentProduct: this.identity.userAgentProduct,
version: this.identity.version,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the identity user-agent suffix

When a host passes identity.userAgentSuffix, the local RPC client now rebuilds the headers with only userAgentProduct and version, so createKimiDefaultHeaders no longer receives the suffix and the generated User-Agent silently loses the host-provided qualifier. This regresses SDK callers that use the public KimiHostIdentity.userAgentSuffix to distinguish integrations; pass the full identity through as before instead of selecting only these two fields.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant