Skip to content

Commit adf8976

Browse files
mmyzwlclaude
andcommitted
refactor: use isRecord() type guard for updatedInput, tighten test types
- Replace unsafe `as Record<string, unknown>` type assertion with type-safe `isRecord(request.input) ? request.input : {}` guard in allow response - Update test type annotations from `behavior: string` to literal `"allow"` and `updatedInput?: Record` to required `updatedInput: Record` Co-Authored-By: Claude <[email protected]>
1 parent 04a4141 commit adf8976

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/agents/cli-runner.spawn.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ ${JSON.stringify({
19611961
response: {
19621962
subtype: string;
19631963
request_id: string;
1964-
response: { behavior: string; updatedInput?: Record<string, unknown>; toolUseID?: string };
1964+
response: { behavior: "allow"; updatedInput: Record<string, unknown>; toolUseID?: string };
19651965
};
19661966
};
19671967
expect(parsed.type).toBe("control_response");
@@ -2332,7 +2332,7 @@ ${JSON.stringify({
23322332
response: {
23332333
subtype: string;
23342334
request_id: string;
2335-
response: { behavior: string; updatedInput?: Record<string, unknown>; toolUseID?: string };
2335+
response: { behavior: "allow"; updatedInput: Record<string, unknown>; toolUseID?: string };
23362336
};
23372337
};
23382338
expect(parsed.response.response.updatedInput).toEqual({ command: "echo hi" });
@@ -2769,7 +2769,7 @@ ${JSON.stringify({
27692769
response: {
27702770
subtype: string;
27712771
request_id: string;
2772-
response: { behavior: string; updatedInput?: Record<string, unknown>; toolUseID?: string };
2772+
response: { behavior: "allow"; updatedInput: Record<string, unknown>; toolUseID?: string };
27732773
};
27742774
};
27752775
expect(parsed.response.response.updatedInput).toEqual({ command: "ls" });

src/agents/cli-runner/claude-live-session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ function handleClaudeLiveControlRequest(
878878
response: allowed
879879
? {
880880
behavior: "allow",
881-
updatedInput: (request.input ?? {}) as Record<string, unknown>,
881+
updatedInput: isRecord(request.input) ? request.input : {},
882882
...(toolUseId ? { toolUseID: toolUseId } : {}),
883883
}
884884
: {

0 commit comments

Comments
 (0)