@opencow-ai/opencow-agent-sdk 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -549,12 +549,15 @@ export declare const SDKHookCallbackRequestSchema: () => z.ZodObject<{
549
549
  }, z.core.$strip>, z.ZodObject<{
550
550
  hook_event_name: z.ZodLiteral<"SessionEnd">;
551
551
  reason: z.ZodEnum<{
552
+ error: "error";
552
553
  resume: "resume";
553
554
  clear: "clear";
554
555
  logout: "logout";
555
556
  prompt_input_exit: "prompt_input_exit";
556
- other: "other";
557
557
  bypass_permissions_disabled: "bypass_permissions_disabled";
558
+ normal: "normal";
559
+ aborted: "aborted";
560
+ other: "other";
558
561
  }>;
559
562
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
560
563
  session_id: z.ZodString;
@@ -1403,12 +1406,15 @@ export declare const SDKControlRequestInnerSchema: () => z.ZodUnion<readonly [z.
1403
1406
  }, z.core.$strip>, z.ZodObject<{
1404
1407
  hook_event_name: z.ZodLiteral<"SessionEnd">;
1405
1408
  reason: z.ZodEnum<{
1409
+ error: "error";
1406
1410
  resume: "resume";
1407
1411
  clear: "clear";
1408
1412
  logout: "logout";
1409
1413
  prompt_input_exit: "prompt_input_exit";
1410
- other: "other";
1411
1414
  bypass_permissions_disabled: "bypass_permissions_disabled";
1415
+ normal: "normal";
1416
+ aborted: "aborted";
1417
+ other: "other";
1412
1418
  }>;
1413
1419
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
1414
1420
  session_id: z.ZodString;
@@ -2160,12 +2166,15 @@ export declare const SDKControlRequestSchema: () => z.ZodObject<{
2160
2166
  }, z.core.$strip>, z.ZodObject<{
2161
2167
  hook_event_name: z.ZodLiteral<"SessionEnd">;
2162
2168
  reason: z.ZodEnum<{
2169
+ error: "error";
2163
2170
  resume: "resume";
2164
2171
  clear: "clear";
2165
2172
  logout: "logout";
2166
2173
  prompt_input_exit: "prompt_input_exit";
2167
- other: "other";
2168
2174
  bypass_permissions_disabled: "bypass_permissions_disabled";
2175
+ normal: "normal";
2176
+ aborted: "aborted";
2177
+ other: "other";
2169
2178
  }>;
2170
2179
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
2171
2180
  session_id: z.ZodString;
@@ -2927,12 +2936,15 @@ export declare const ControlErrorResponseSchema: () => z.ZodObject<{
2927
2936
  }, z.core.$strip>, z.ZodObject<{
2928
2937
  hook_event_name: z.ZodLiteral<"SessionEnd">;
2929
2938
  reason: z.ZodEnum<{
2939
+ error: "error";
2930
2940
  resume: "resume";
2931
2941
  clear: "clear";
2932
2942
  logout: "logout";
2933
2943
  prompt_input_exit: "prompt_input_exit";
2934
- other: "other";
2935
2944
  bypass_permissions_disabled: "bypass_permissions_disabled";
2945
+ normal: "normal";
2946
+ aborted: "aborted";
2947
+ other: "other";
2936
2948
  }>;
2937
2949
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
2938
2950
  session_id: z.ZodString;
@@ -3696,12 +3708,15 @@ export declare const SDKControlResponseSchema: () => z.ZodObject<{
3696
3708
  }, z.core.$strip>, z.ZodObject<{
3697
3709
  hook_event_name: z.ZodLiteral<"SessionEnd">;
3698
3710
  reason: z.ZodEnum<{
3711
+ error: "error";
3699
3712
  resume: "resume";
3700
3713
  clear: "clear";
3701
3714
  logout: "logout";
3702
3715
  prompt_input_exit: "prompt_input_exit";
3703
- other: "other";
3704
3716
  bypass_permissions_disabled: "bypass_permissions_disabled";
3717
+ normal: "normal";
3718
+ aborted: "aborted";
3719
+ other: "other";
3705
3720
  }>;
3706
3721
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
3707
3722
  session_id: z.ZodString;
@@ -4907,12 +4922,15 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
4907
4922
  }, z.core.$strip>, z.ZodObject<{
4908
4923
  hook_event_name: z.ZodLiteral<"SessionEnd">;
4909
4924
  reason: z.ZodEnum<{
4925
+ error: "error";
4910
4926
  resume: "resume";
4911
4927
  clear: "clear";
4912
4928
  logout: "logout";
4913
4929
  prompt_input_exit: "prompt_input_exit";
4914
- other: "other";
4915
4930
  bypass_permissions_disabled: "bypass_permissions_disabled";
4931
+ normal: "normal";
4932
+ aborted: "aborted";
4933
+ other: "other";
4916
4934
  }>;
4917
4935
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
4918
4936
  session_id: z.ZodString;
@@ -5666,12 +5684,15 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
5666
5684
  }, z.core.$strip>, z.ZodObject<{
5667
5685
  hook_event_name: z.ZodLiteral<"SessionEnd">;
5668
5686
  reason: z.ZodEnum<{
5687
+ error: "error";
5669
5688
  resume: "resume";
5670
5689
  clear: "clear";
5671
5690
  logout: "logout";
5672
5691
  prompt_input_exit: "prompt_input_exit";
5673
- other: "other";
5674
5692
  bypass_permissions_disabled: "bypass_permissions_disabled";
5693
+ normal: "normal";
5694
+ aborted: "aborted";
5695
+ other: "other";
5675
5696
  }>;
5676
5697
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
5677
5698
  session_id: z.ZodString;
@@ -6443,12 +6464,15 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
6443
6464
  }, z.core.$strip>, z.ZodObject<{
6444
6465
  hook_event_name: z.ZodLiteral<"SessionEnd">;
6445
6466
  reason: z.ZodEnum<{
6467
+ error: "error";
6446
6468
  resume: "resume";
6447
6469
  clear: "clear";
6448
6470
  logout: "logout";
6449
6471
  prompt_input_exit: "prompt_input_exit";
6450
- other: "other";
6451
6472
  bypass_permissions_disabled: "bypass_permissions_disabled";
6473
+ normal: "normal";
6474
+ aborted: "aborted";
6475
+ other: "other";
6452
6476
  }>;
6453
6477
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
6454
6478
  session_id: z.ZodString;
@@ -7210,12 +7234,15 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
7210
7234
  }, z.core.$strip>, z.ZodObject<{
7211
7235
  hook_event_name: z.ZodLiteral<"SessionEnd">;
7212
7236
  reason: z.ZodEnum<{
7237
+ error: "error";
7213
7238
  resume: "resume";
7214
7239
  clear: "clear";
7215
7240
  logout: "logout";
7216
7241
  prompt_input_exit: "prompt_input_exit";
7217
- other: "other";
7218
7242
  bypass_permissions_disabled: "bypass_permissions_disabled";
7243
+ normal: "normal";
7244
+ aborted: "aborted";
7245
+ other: "other";
7219
7246
  }>;
7220
7247
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
7221
7248
  session_id: z.ZodString;
@@ -931,14 +931,17 @@ export declare const FileChangedHookInputSchema: () => z.ZodIntersection<z.ZodOb
931
931
  unlink: "unlink";
932
932
  }>;
933
933
  }, z.core.$strip>>;
934
- export declare const EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];
934
+ export declare const EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "bypass_permissions_disabled", "normal", "aborted", "error", "other"];
935
935
  export declare const ExitReasonSchema: () => z.ZodEnum<{
936
+ error: "error";
936
937
  resume: "resume";
937
938
  clear: "clear";
938
939
  logout: "logout";
939
940
  prompt_input_exit: "prompt_input_exit";
940
- other: "other";
941
941
  bypass_permissions_disabled: "bypass_permissions_disabled";
942
+ normal: "normal";
943
+ aborted: "aborted";
944
+ other: "other";
942
945
  }>;
943
946
  export declare const SessionEndHookInputSchema: () => z.ZodIntersection<z.ZodObject<{
944
947
  session_id: z.ZodString;
@@ -950,12 +953,15 @@ export declare const SessionEndHookInputSchema: () => z.ZodIntersection<z.ZodObj
950
953
  }, z.core.$strip>, z.ZodObject<{
951
954
  hook_event_name: z.ZodLiteral<"SessionEnd">;
952
955
  reason: z.ZodEnum<{
956
+ error: "error";
953
957
  resume: "resume";
954
958
  clear: "clear";
955
959
  logout: "logout";
956
960
  prompt_input_exit: "prompt_input_exit";
957
- other: "other";
958
961
  bypass_permissions_disabled: "bypass_permissions_disabled";
962
+ normal: "normal";
963
+ aborted: "aborted";
964
+ other: "other";
959
965
  }>;
960
966
  }, z.core.$strip>>;
961
967
  export declare const HookInputSchema: () => z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
@@ -1059,12 +1065,15 @@ export declare const HookInputSchema: () => z.ZodUnion<readonly [z.ZodIntersecti
1059
1065
  }, z.core.$strip>, z.ZodObject<{
1060
1066
  hook_event_name: z.ZodLiteral<"SessionEnd">;
1061
1067
  reason: z.ZodEnum<{
1068
+ error: "error";
1062
1069
  resume: "resume";
1063
1070
  clear: "clear";
1064
1071
  logout: "logout";
1065
1072
  prompt_input_exit: "prompt_input_exit";
1066
- other: "other";
1067
1073
  bypass_permissions_disabled: "bypass_permissions_disabled";
1074
+ normal: "normal";
1075
+ aborted: "aborted";
1076
+ other: "other";
1068
1077
  }>;
1069
1078
  }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
1070
1079
  session_id: z.ZodString;
@@ -2,4 +2,4 @@ export type { SandboxFilesystemConfig, SandboxIgnoreViolations, SandboxNetworkCo
2
2
  export * from './coreTypes.generated.js';
3
3
  export type { NonNullableUsage } from './sdkUtilityTypes.js';
4
4
  export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged"];
5
- export declare const EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];
5
+ export declare const EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "bypass_permissions_disabled", "normal", "aborted", "error", "other"];
@@ -2,7 +2,7 @@ import type { ChildProcessWithoutNullStreams } from 'node:child_process';
2
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
4
4
  import type { z } from 'zod/v4';
5
- import type { HookEvent, HookInput, SDKMessage, SDKResultMessage, SDKSessionInfo, SDKUserMessage, SyncHookJSONOutput } from './coreTypes.js';
5
+ import type { ExitReason, HookEvent, HookInput, SDKMessage, SDKResultMessage, SDKSessionInfo, SDKUserMessage, SyncHookJSONOutput } from './coreTypes.js';
6
6
  export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
7
7
  export type AnyZodRawShape = z.ZodRawShape;
8
8
  export type InferShape<Shape extends AnyZodRawShape = AnyZodRawShape> = z.infer<z.ZodObject<Shape>>;
@@ -422,7 +422,22 @@ export type SDKSession = {
422
422
  }): Query;
423
423
  prompt(message: string, options?: Options): Promise<SDKResultMessage>;
424
424
  getInfo(): Promise<SDKSessionInfo | undefined>;
425
- close(): Promise<void>;
425
+ /**
426
+ * Tear down the session container and fire the SessionEnd hook once.
427
+ *
428
+ * Per CC/SDK community semantics SessionEnd is a session-lifecycle event
429
+ * (not per-turn / per-query). Hosts call this on:
430
+ * - the user closing the chat / deleting the session (`'aborted'`)
431
+ * - graceful app shutdown or max_turns completion (`'normal'`)
432
+ * - an unrecoverable error tearing the session down (`'error'`)
433
+ * - any other host-defined teardown (`'other'`)
434
+ *
435
+ * `reason` is passed straight through to the SessionEnd hook payload's
436
+ * `reason: ExitReason` field. Default `'normal'` keeps single-arg
437
+ * callers (`session.close()`) backwards-compatible with pre-fire-on-
438
+ * close hosts; new code should pass the most specific reason it knows.
439
+ */
440
+ close(reason?: ExitReason): Promise<void>;
426
441
  /**
427
442
  * 把跟踪的文件回退到 `messageUuid` 对应的 snapshot。
428
443
  *