

























@@ -28,6 +28,14 @@ function textOf(result: ProcessToolResult): string {
2828return item?.type === "text" ? item.text : "";
2929}
303031+function expectRecordFields(record: unknown, expected: Record<string, unknown>) {
32+expect(record).toBeDefined();
33+const actual = record as Record<string, unknown>;
34+for (const [key, value] of Object.entries(expected)) {
35+expect(actual[key]).toEqual(value);
36+}
37+}
38+3139function installWritableStdin(
3240session: ReturnType<typeof createProcessSessionFixture>,
3341state?: { writableEnded?: boolean; writableFinished?: boolean; destroyed?: boolean },
@@ -68,7 +76,7 @@ describe("process input-wait hints", () => {
6876expect(text).toContain("Name? ");
6977expect(text).toContain("No new output for 20s");
7078expect(text).toContain("Use process write, send-keys, submit, or paste to provide input.");
71-expect(result.details).toMatchObject({
79+expectRecordFields(result.details, {
7280status: "running",
7381sessionId: "sess-log-hint",
7482stdinWritable: true,
@@ -98,7 +106,7 @@ describe("process input-wait hints", () => {
9810699107expect(textOf(result)).toContain("(no new output)");
100108expect(textOf(result)).toContain("may be waiting for input");
101-expect(result.details).toMatchObject({
109+expectRecordFields(result.details, {
102110status: "running",
103111sessionId: "sess-poll",
104112stdinWritable: true,
@@ -126,7 +134,7 @@ describe("process input-wait hints", () => {
126134expect(textOf(result)).toContain("sess-list");
127135expect(textOf(result)).toContain("[input-wait]");
128136const sessions = (result.details as { sessions?: Array<Record<string, unknown>> }).sessions;
129-expect(sessions?.[0]).toMatchObject({
137+expectRecordFields(sessions?.[0], {
130138sessionId: "sess-list",
131139stdinWritable: true,
132140waitingForInput: true,
@@ -156,7 +164,7 @@ describe("process input-wait hints", () => {
156164expect(textOf(result)).toContain("Password: ");
157165expect(textOf(result)).toContain("No new output for 25s");
158166expect(textOf(result)).toContain("Use process write, send-keys, submit, or paste");
159-expect(result.details).toMatchObject({
167+expectRecordFields(result.details, {
160168status: "running",
161169sessionId: "sess-log",
162170stdinWritable: true,
@@ -183,7 +191,7 @@ describe("process input-wait hints", () => {
183191sessionId: "sess-ended",
184192});
185193expect(textOf(log)).not.toContain("provide input");
186-expect(log.details).toMatchObject({
194+expectRecordFields(log.details, {
187195status: "running",
188196stdinWritable: false,
189197waitingForInput: false,
@@ -195,7 +203,7 @@ describe("process input-wait hints", () => {
195203data: "answer\n",
196204});
197205expect(textOf(write)).toContain("stdin is not writable");
198-expect(write.details).toMatchObject({ status: "failed" });
206+expectRecordFields(write.details, { status: "failed" });
199207});
200208201209it("can read finished session logs without exposing input controls", async () => {
@@ -216,7 +224,7 @@ describe("process input-wait hints", () => {
216224217225expect(textOf(result)).toContain("done");
218226expect(textOf(result)).not.toContain("provide input");
219-expect(result.details).toMatchObject({
227+expectRecordFields(result.details, {
220228status: "completed",
221229sessionId: "sess-finished",
222230exitCode: 0,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。