Skip to content

refactor: split SDK RPC client#339

Merged
kermanx merged 9 commits into
mainfrom
xtr/split-node-sdk-rpc-client
Jun 3, 2026
Merged

refactor: split SDK RPC client#339
kermanx merged 9 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: a869ec7

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@a869ec7
npx https://pkg.pr.new/@moonshot-ai/kimi-code@a869ec7

commit: a869ec7

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 👍 / 👎.

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: 3ee739d65d

ℹ️ 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".

setContext: setTelemetryContext,
};
const harness = new KimiHarness({
const harness = createKimiHarness({
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 Mock createKimiHarness in goal prompt tests

When runPrompt is exercised by apps/kimi-code/test/cli/goal-prompt.test.ts, that suite's SDK mock still overrides only KimiHarness, not createKimiHarness; this changed call therefore instantiates the real local SDK harness instead of the fake session, so the headless goal tests no longer drive mocks.session and can fail or touch real SDK state. Update that remaining mock as the other CLI tests do before switching this path.

Useful? React with 👍 / 👎.

@kermanx kermanx merged commit a6b16ce into main Jun 3, 2026
8 checks passed
@kermanx kermanx deleted the xtr/split-node-sdk-rpc-client branch June 3, 2026 07:30
@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
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