Skip to content

Commit 6d8458e

Browse files
koki-developclaude
andcommitted
feat: Add signal and status fields to SandboxStageResult
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2e92063 commit 6d8458e

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

typescript/src/client.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const sampleRunResult = {
2424
stderr: "",
2525
output: "Hello\n",
2626
exit_code: 0,
27+
signal: null,
28+
status: "SUCCESS",
2729
};
2830

2931
const sampleRequest = {
@@ -120,8 +122,10 @@ describe("CodizeClient", () => {
120122
stderr: "",
121123
output: "",
122124
exit_code: 0,
125+
signal: null,
126+
status: "SUCCESS",
123127
},
124-
run: { stdout: "ok\n", stderr: "", output: "ok\n", exit_code: 0 },
128+
run: { stdout: "ok\n", stderr: "", output: "ok\n", exit_code: 0, signal: null, status: "SUCCESS" },
125129
};
126130
const fetchFn = vi.fn().mockResolvedValue(makeJsonResponse(body));
127131
const client = new CodizeClient({ apiKey: "key", fetchFn });
@@ -132,19 +136,23 @@ describe("CodizeClient", () => {
132136
stderr: "",
133137
output: "",
134138
exitCode: 0,
139+
signal: null,
140+
status: "SUCCESS",
135141
});
136142
expect(result.data.run).toEqual({
137143
stdout: "ok\n",
138144
stderr: "",
139145
output: "ok\n",
140146
exitCode: 0,
147+
signal: null,
148+
status: "SUCCESS",
141149
});
142150
});
143151

144152
it("returns compile as null when the API returns null", async () => {
145153
const body = {
146154
compile: null,
147-
run: { stdout: "", stderr: "", output: "", exit_code: 0 },
155+
run: { stdout: "", stderr: "", output: "", exit_code: 0, signal: null, status: "SUCCESS" },
148156
};
149157
const fetchFn = vi.fn().mockResolvedValue(makeJsonResponse(body));
150158
const client = new CodizeClient({ apiKey: "key", fetchFn });

typescript/src/client.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ export type SandboxExecuteResponse = {
7575
};
7676
};
7777

78+
/**
79+
* Execution status of a sandbox stage.
80+
*/
81+
export type SandboxStageStatus =
82+
| "SUCCESS"
83+
| "RUNTIME_ERROR"
84+
| "SIGNAL"
85+
| "TIMEOUT"
86+
| "OUTPUT_LIMIT_EXCEEDED"
87+
| "ERROR_LIMIT_EXCEEDED"
88+
| (string & {});
89+
7890
/**
7991
* Output for a single sandbox stage (compile or run).
8092
*/
@@ -95,6 +107,14 @@ export type SandboxStageResult = {
95107
* Process exit code.
96108
*/
97109
exitCode: number | null;
110+
/**
111+
* Signal name that terminated the process, or null if not terminated by a signal.
112+
*/
113+
signal: string | null;
114+
/**
115+
* Execution status.
116+
*/
117+
status: SandboxStageStatus;
98118
};
99119

100120
/**
@@ -105,6 +125,8 @@ type RawStageResult = {
105125
stderr: string;
106126
output: string;
107127
exit_code: number | null;
128+
signal: string | null;
129+
status: SandboxStageStatus;
108130
};
109131

110132
/**
@@ -116,6 +138,8 @@ function mapStageResult(raw: RawStageResult): SandboxStageResult {
116138
stderr: raw.stderr,
117139
output: raw.output,
118140
exitCode: raw.exit_code,
141+
signal: raw.signal,
142+
status: raw.status,
119143
};
120144
}
121145

typescript/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
type SandboxExecuteRequest,
88
type SandboxExecuteResponse,
99
type SandboxStageResult,
10+
type SandboxStageStatus,
1011
} from "./client";
1112

1213
/**

0 commit comments

Comments
 (0)