Fix typescript samples in documentation#610
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes TypeScript documentation samples across the Node.js SDK to work correctly with version 0.1.29+ of the library, where onPermissionRequest became a required parameter in SessionConfig and ResumeSessionConfig. It also updates the Node.js version requirement in the getting-started guide to reflect the minimum needed for node:sqlite support.
Changes:
- Add
onPermissionRequest: async () => ({ kind: "approved" })to all TypeScriptcreateSession()andresumeSession()call sites across docs and examples - Update Node.js version requirement in
docs/getting-started.mdfrom18+to22.13.0+ / 23.5.0+ / 24+ - Update function signatures
createSession(config?: SessionConfig)→createSession(config: SessionConfig)andresumeSession(sessionId, config?)→resumeSession(sessionId, config)to reflect that config is now required
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
nodejs/examples/basic-example.ts |
Adds onPermissionRequest to the example createSession call |
nodejs/README.md |
Updates function signatures, adds onPermissionRequest to all code samples and config docs |
docs/getting-started.md |
Updates Node.js version requirement; adds onPermissionRequest to TypeScript samples |
docs/mcp/overview.md |
Adds onPermissionRequest to TypeScript createSession calls |
docs/hooks/user-prompt-submitted.md |
Adds onPermissionRequest to all TypeScript samples; removes trailing whitespace |
docs/hooks/session-lifecycle.md |
Adds onPermissionRequest to all TypeScript samples; removes trailing whitespace |
docs/hooks/pre-tool-use.md |
Adds onPermissionRequest to all TypeScript samples; removes trailing whitespace |
docs/hooks/post-tool-use.md |
Adds onPermissionRequest to all TypeScript samples; removes trailing whitespace |
docs/hooks/overview.md |
Adds onPermissionRequest to TypeScript samples |
docs/hooks/error-handling.md |
Adds onPermissionRequest to all TypeScript samples; removes trailing whitespace |
docs/guides/skills.md |
Adds onPermissionRequest to the createSession call with disabledSkills |
docs/guides/setup/scaling.md |
Adds onPermissionRequest to createSession and resumeSession calls |
docs/guides/setup/local-cli.md |
Adds onPermissionRequest to both createSession and resumeSession calls |
docs/guides/setup/github-oauth.md |
Adds onPermissionRequest to the session creation example |
docs/guides/setup/byok.md |
Adds onPermissionRequest to all createSession and resumeSession samples |
docs/guides/setup/bundled-cli.md |
Adds onPermissionRequest to createSession and resumeSession samples |
docs/guides/setup/backend-services.md |
Adds onPermissionRequest to all session creation/resumption calls |
docs/guides/setup/azure-managed-identity.md |
Adds onPermissionRequest to the TypeScript createSession example |
docs/guides/session-persistence.md |
Adds onPermissionRequest to createSession and resumeSession samples; removes trailing whitespace |
docs/debugging.md |
Adds onPermissionRequest to the createSession snippet; removes trailing whitespace |
docs/compatibility.md |
Adds onPermissionRequest to the context compaction example |
docs/auth/byok.md |
Adds onPermissionRequest to BYOK session examples |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@patniko Could you please review this again? I accepted the change from copilot after your approval |
|
@SteveSandersonMS , it seems that #879 only includes changes to
Aren’t these changes also necessary? |
|
For other |
Add
onPermissionRequestto parameters ofcreateSessionandresumeSessionAs of
0.1.29,onPermissionRequestis required inSessionConfig, socreateSessionandresumeSessionthrow an exception when the parameter isnullorundefined.Update Node.js version
When
createSessionis executed, GitHub Copilot CLI (or SDK? not sure.) seems to try to loadnode:sqliteand usesqlite.constants.They are available in
22.13.0+ / 23.5.0+ / 24+