Skip to content

Commit 4ea1241

Browse files
Add sessionId to all hook input types consistently across Python and .NET
- Python: Add sessionId to UserPromptSubmittedHookInput, SessionStartHookInput, SessionEndHookInput, ErrorOccurredHookInput. Remove unused BaseHookInput. - .NET: Add SessionId to UserPromptSubmittedHookInput, SessionStartHookInput, SessionEndHookInput, ErrorOccurredHookInput. All 6 hook input types now have sessionId in every SDK (Node, Python, Go, .NET, Rust). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0691f1f commit 4ea1241

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

dotnet/src/Types.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,12 @@ public class PostToolUseHookOutput
12531253
/// </summary>
12541254
public class UserPromptSubmittedHookInput
12551255
{
1256+
/// <summary>
1257+
/// The runtime session ID of the session that triggered the hook.
1258+
/// </summary>
1259+
[JsonPropertyName("sessionId")]
1260+
public string SessionId { get; set; } = string.Empty;
1261+
12561262
/// <summary>
12571263
/// Unix timestamp in milliseconds when the prompt was submitted.
12581264
/// </summary>
@@ -1306,6 +1312,12 @@ public class UserPromptSubmittedHookOutput
13061312
/// </summary>
13071313
public class SessionStartHookInput
13081314
{
1315+
/// <summary>
1316+
/// The runtime session ID of the session that triggered the hook.
1317+
/// </summary>
1318+
[JsonPropertyName("sessionId")]
1319+
public string SessionId { get; set; } = string.Empty;
1320+
13091321
/// <summary>
13101322
/// Unix timestamp in milliseconds when the session started.
13111323
/// </summary>
@@ -1364,6 +1376,12 @@ public class SessionStartHookOutput
13641376
/// </summary>
13651377
public class SessionEndHookInput
13661378
{
1379+
/// <summary>
1380+
/// The runtime session ID of the session that triggered the hook.
1381+
/// </summary>
1382+
[JsonPropertyName("sessionId")]
1383+
public string SessionId { get; set; } = string.Empty;
1384+
13671385
/// <summary>
13681386
/// Unix timestamp in milliseconds when the session ended.
13691387
/// </summary>
@@ -1436,6 +1454,12 @@ public class SessionEndHookOutput
14361454
/// </summary>
14371455
public class ErrorOccurredHookInput
14381456
{
1457+
/// <summary>
1458+
/// The runtime session ID of the session that triggered the hook.
1459+
/// </summary>
1460+
[JsonPropertyName("sessionId")]
1461+
public string SessionId { get; set; } = string.Empty;
1462+
14391463
/// <summary>
14401464
/// Unix timestamp in milliseconds when the error occurred.
14411465
/// </summary>

python/copilot/session.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,6 @@ async def input(self, message: str, options: InputOptions | None = None) -> str
610610
# ============================================================================
611611

612612

613-
class BaseHookInput(TypedDict):
614-
"""Base interface for all hook inputs"""
615-
616-
sessionId: str
617-
timestamp: int
618-
cwd: str
619-
620-
621613
class PreToolUseHookInput(TypedDict):
622614
"""Input for pre-tool-use hook"""
623615

@@ -672,6 +664,7 @@ class PostToolUseHookOutput(TypedDict, total=False):
672664
class UserPromptSubmittedHookInput(TypedDict):
673665
"""Input for user-prompt-submitted hook"""
674666

667+
sessionId: str
675668
timestamp: int
676669
cwd: str
677670
prompt: str
@@ -694,6 +687,7 @@ class UserPromptSubmittedHookOutput(TypedDict, total=False):
694687
class SessionStartHookInput(TypedDict):
695688
"""Input for session-start hook"""
696689

690+
sessionId: str
697691
timestamp: int
698692
cwd: str
699693
source: Literal["startup", "resume", "new"]
@@ -716,6 +710,7 @@ class SessionStartHookOutput(TypedDict, total=False):
716710
class SessionEndHookInput(TypedDict):
717711
"""Input for session-end hook"""
718712

713+
sessionId: str
719714
timestamp: int
720715
cwd: str
721716
reason: Literal["complete", "error", "abort", "timeout", "user_exit"]
@@ -740,6 +735,7 @@ class SessionEndHookOutput(TypedDict, total=False):
740735
class ErrorOccurredHookInput(TypedDict):
741736
"""Input for error-occurred hook"""
742737

738+
sessionId: str
743739
timestamp: int
744740
cwd: str
745741
error: str

0 commit comments

Comments
 (0)