c64-debug-mcp 1.0.9 → 1.0.11

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.
package/dist/http.cjs CHANGED
@@ -213,7 +213,7 @@ function parseAddress16(input) {
213
213
  }
214
214
  return parsed;
215
215
  }
216
- var address16Schema = import_zod2.z.preprocess(parseAddress16, import_zod2.z.number().int().min(0).max(65535)).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
216
+ var address16Schema = import_zod2.z.union([import_zod2.z.number().int().min(0).max(65535), import_zod2.z.string()]).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
217
217
  function parseByte(input) {
218
218
  if (typeof input === "number") {
219
219
  if (!Number.isInteger(input) || input < 0 || input > 255) {
@@ -337,7 +337,7 @@ function parseByte(input) {
337
337
  }
338
338
  ]);
339
339
  }
340
- var byteValueSchema = import_zod2.z.preprocess(parseByte, import_zod2.z.number().int().min(0).max(255)).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
340
+ var byteValueSchema = import_zod2.z.union([import_zod2.z.number().int().min(0).max(255), import_zod2.z.string()]).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
341
341
  var byteArraySchema = import_zod2.z.array(byteValueSchema).describe('Array of byte values in mixed formats: [255, "$FF", "%11111111", 42]');
342
342
  var c64RegisterValueSchema = import_zod2.z.object(
343
343
  Object.fromEntries(
@@ -3646,30 +3646,35 @@ var readMemoryTool = createViceTool({
3646
3646
  start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3647
3647
  end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3648
3648
  })
3649
- ]).transform((input) => {
3650
- if ("start" in input && "end" in input) {
3651
- if (input.end < input.start) {
3652
- throw new Error("End address must be greater than or equal to start address");
3653
- }
3654
- return {
3655
- address: input.start,
3656
- length: input.end - input.start + 1
3657
- };
3658
- }
3659
- return input;
3660
- }).refine((input) => input.address + input.length <= 65536, {
3661
- message: "address + length must stay within the 64K address space",
3662
- path: ["length"]
3663
- }),
3649
+ ]),
3664
3650
  dataSchema: import_zod4.z.object({
3665
3651
  address: address16Schema.describe("Start address of the returned memory chunk"),
3666
3652
  length: import_zod4.z.number().int().min(0).describe("Number of bytes returned"),
3667
3653
  data: byteArraySchema.describe("Raw bytes returned from memory")
3668
3654
  }),
3669
3655
  execute: async (input) => {
3670
- const result = await c64Session.readMemory(input.address, input.address + input.length - 1);
3656
+ let address;
3657
+ let length;
3658
+ if ("start" in input && "end" in input) {
3659
+ const start = parseAddress16(input.start);
3660
+ const end = parseAddress16(input.end);
3661
+ if (end < start) {
3662
+ throw new Error("End address must be greater than or equal to start address");
3663
+ }
3664
+ address = start;
3665
+ length = end - start + 1;
3666
+ } else if ("address" in input && "length" in input) {
3667
+ address = parseAddress16(input.address);
3668
+ length = input.length;
3669
+ } else {
3670
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3671
+ }
3672
+ if (address + length > 65536) {
3673
+ throw new Error("address + length must stay within the 64K address space");
3674
+ }
3675
+ const result = await c64Session.readMemory(address, address + length - 1);
3671
3676
  return {
3672
- address: input.address,
3677
+ address,
3673
3678
  length: result.length,
3674
3679
  data: result.data
3675
3680
  };
@@ -3681,16 +3686,20 @@ var writeMemoryTool = createViceTool({
3681
3686
  inputSchema: import_zod4.z.object({
3682
3687
  address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3683
3688
  data: byteArraySchema.min(1).describe("Bytes to write: decimal (255), hex ($FF, 0xFF), or binary (%11111111, 0b11111111). Mixed formats allowed.")
3684
- }).refine((input) => input.address + input.data.length - 1 <= 65535, {
3685
- message: "address + data.length must stay within the 16-bit address space",
3686
- path: ["data"]
3687
3689
  }),
3688
3690
  dataSchema: import_zod4.z.object({
3689
3691
  worked: import_zod4.z.boolean().describe("Whether the write operation completed successfully"),
3690
- address: address16Schema.describe("Start address where the bytes were written"),
3692
+ address: import_zod4.z.number().int().min(0).max(65535).describe("Start address where the bytes were written"),
3691
3693
  length: import_zod4.z.number().int().min(1).describe("Number of bytes written")
3692
3694
  }).extend(debugStateSchema.shape),
3693
- execute: async (input) => await c64Session.writeMemory(input.address, input.data)
3695
+ execute: async (input) => {
3696
+ const address = parseAddress16(input.address);
3697
+ const data = input.data.map((b) => parseByte(b));
3698
+ if (address + data.length - 1 > 65535) {
3699
+ throw new Error("address + data.length must stay within the 16-bit address space");
3700
+ }
3701
+ return await c64Session.writeMemory(address, data);
3702
+ }
3694
3703
  });
3695
3704
  var executeTool = createViceTool({
3696
3705
  id: "execute",
@@ -3737,36 +3746,26 @@ var listBreakpointsTool = createViceTool({
3737
3746
  var breakpointSetTool = createViceTool({
3738
3747
  id: "breakpoint_set",
3739
3748
  description: "Creates an execution breakpoint or read/write watchpoint. Use either (address, length) or (start, end) format. Addresses can be decimal (53248) or hex string with prefix ($D000, 0xD000).",
3740
- inputSchema: import_zod4.z.object({
3741
- kind: breakpointKindSchema,
3742
- condition: import_zod4.z.string().optional(),
3743
- label: import_zod4.z.string().optional(),
3744
- temporary: import_zod4.z.boolean().default(false),
3745
- enabled: import_zod4.z.boolean().default(true)
3746
- }).and(
3747
- import_zod4.z.union([
3748
- import_zod4.z.object({
3749
- address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3750
- length: import_zod4.z.number().int().positive().default(1).describe("Size of the breakpoint range in bytes")
3751
- }),
3752
- import_zod4.z.object({
3753
- start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3754
- end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3755
- })
3756
- ])
3757
- ).transform((input) => {
3758
- if ("start" in input && "end" in input) {
3759
- if (input.end < input.start) {
3760
- throw new Error("End address must be greater than or equal to start address");
3761
- }
3762
- return {
3763
- ...input,
3764
- address: input.start,
3765
- length: input.end - input.start + 1
3766
- };
3767
- }
3768
- return input;
3769
- }),
3749
+ inputSchema: import_zod4.z.union([
3750
+ import_zod4.z.object({
3751
+ kind: breakpointKindSchema,
3752
+ address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3753
+ length: import_zod4.z.number().int().positive().default(1).describe("Size of the breakpoint range in bytes"),
3754
+ condition: import_zod4.z.string().optional(),
3755
+ label: import_zod4.z.string().optional(),
3756
+ temporary: import_zod4.z.boolean().default(false),
3757
+ enabled: import_zod4.z.boolean().default(true)
3758
+ }),
3759
+ import_zod4.z.object({
3760
+ kind: breakpointKindSchema,
3761
+ start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3762
+ end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3763
+ condition: import_zod4.z.string().optional(),
3764
+ label: import_zod4.z.string().optional(),
3765
+ temporary: import_zod4.z.boolean().default(false),
3766
+ enabled: import_zod4.z.boolean().default(true)
3767
+ })
3768
+ ]),
3770
3769
  dataSchema: import_zod4.z.object({
3771
3770
  breakpoint: breakpointSchema,
3772
3771
  executionState: executionStateSchema,
@@ -3775,7 +3774,36 @@ var breakpointSetTool = createViceTool({
3775
3774
  registers: c64PartialRegisterValueSchema.nullable()
3776
3775
  }),
3777
3776
  execute: async (input) => {
3778
- const result = await c64Session.breakpointSet(input);
3777
+ let normalizedInput;
3778
+ if ("start" in input && "end" in input) {
3779
+ const start = parseAddress16(input.start);
3780
+ const end = parseAddress16(input.end);
3781
+ if (end < start) {
3782
+ throw new Error("End address must be greater than or equal to start address");
3783
+ }
3784
+ normalizedInput = {
3785
+ kind: input.kind,
3786
+ address: start,
3787
+ length: end - start + 1,
3788
+ condition: input.condition,
3789
+ label: input.label,
3790
+ temporary: input.temporary,
3791
+ enabled: input.enabled
3792
+ };
3793
+ } else if ("address" in input && "length" in input) {
3794
+ normalizedInput = {
3795
+ kind: input.kind,
3796
+ address: parseAddress16(input.address),
3797
+ length: input.length,
3798
+ condition: input.condition,
3799
+ label: input.label,
3800
+ temporary: input.temporary,
3801
+ enabled: input.enabled
3802
+ };
3803
+ } else {
3804
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3805
+ }
3806
+ const result = await c64Session.breakpointSet(normalizedInput);
3779
3807
  return {
3780
3808
  breakpoint: normalizeBreakpoint(result.breakpoint),
3781
3809
  executionState: result.executionState,
package/dist/http.js CHANGED
@@ -190,7 +190,7 @@ function parseAddress16(input) {
190
190
  }
191
191
  return parsed;
192
192
  }
193
- var address16Schema = z2.preprocess(parseAddress16, z2.number().int().min(0).max(65535)).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
193
+ var address16Schema = z2.union([z2.number().int().min(0).max(65535), z2.string()]).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
194
194
  function parseByte(input) {
195
195
  if (typeof input === "number") {
196
196
  if (!Number.isInteger(input) || input < 0 || input > 255) {
@@ -314,7 +314,7 @@ function parseByte(input) {
314
314
  }
315
315
  ]);
316
316
  }
317
- var byteValueSchema = z2.preprocess(parseByte, z2.number().int().min(0).max(255)).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
317
+ var byteValueSchema = z2.union([z2.number().int().min(0).max(255), z2.string()]).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
318
318
  var byteArraySchema = z2.array(byteValueSchema).describe('Array of byte values in mixed formats: [255, "$FF", "%11111111", 42]');
319
319
  var c64RegisterValueSchema = z2.object(
320
320
  Object.fromEntries(
@@ -3623,30 +3623,35 @@ var readMemoryTool = createViceTool({
3623
3623
  start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3624
3624
  end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3625
3625
  })
3626
- ]).transform((input) => {
3627
- if ("start" in input && "end" in input) {
3628
- if (input.end < input.start) {
3629
- throw new Error("End address must be greater than or equal to start address");
3630
- }
3631
- return {
3632
- address: input.start,
3633
- length: input.end - input.start + 1
3634
- };
3635
- }
3636
- return input;
3637
- }).refine((input) => input.address + input.length <= 65536, {
3638
- message: "address + length must stay within the 64K address space",
3639
- path: ["length"]
3640
- }),
3626
+ ]),
3641
3627
  dataSchema: z3.object({
3642
3628
  address: address16Schema.describe("Start address of the returned memory chunk"),
3643
3629
  length: z3.number().int().min(0).describe("Number of bytes returned"),
3644
3630
  data: byteArraySchema.describe("Raw bytes returned from memory")
3645
3631
  }),
3646
3632
  execute: async (input) => {
3647
- const result = await c64Session.readMemory(input.address, input.address + input.length - 1);
3633
+ let address;
3634
+ let length;
3635
+ if ("start" in input && "end" in input) {
3636
+ const start = parseAddress16(input.start);
3637
+ const end = parseAddress16(input.end);
3638
+ if (end < start) {
3639
+ throw new Error("End address must be greater than or equal to start address");
3640
+ }
3641
+ address = start;
3642
+ length = end - start + 1;
3643
+ } else if ("address" in input && "length" in input) {
3644
+ address = parseAddress16(input.address);
3645
+ length = input.length;
3646
+ } else {
3647
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3648
+ }
3649
+ if (address + length > 65536) {
3650
+ throw new Error("address + length must stay within the 64K address space");
3651
+ }
3652
+ const result = await c64Session.readMemory(address, address + length - 1);
3648
3653
  return {
3649
- address: input.address,
3654
+ address,
3650
3655
  length: result.length,
3651
3656
  data: result.data
3652
3657
  };
@@ -3658,16 +3663,20 @@ var writeMemoryTool = createViceTool({
3658
3663
  inputSchema: z3.object({
3659
3664
  address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3660
3665
  data: byteArraySchema.min(1).describe("Bytes to write: decimal (255), hex ($FF, 0xFF), or binary (%11111111, 0b11111111). Mixed formats allowed.")
3661
- }).refine((input) => input.address + input.data.length - 1 <= 65535, {
3662
- message: "address + data.length must stay within the 16-bit address space",
3663
- path: ["data"]
3664
3666
  }),
3665
3667
  dataSchema: z3.object({
3666
3668
  worked: z3.boolean().describe("Whether the write operation completed successfully"),
3667
- address: address16Schema.describe("Start address where the bytes were written"),
3669
+ address: z3.number().int().min(0).max(65535).describe("Start address where the bytes were written"),
3668
3670
  length: z3.number().int().min(1).describe("Number of bytes written")
3669
3671
  }).extend(debugStateSchema.shape),
3670
- execute: async (input) => await c64Session.writeMemory(input.address, input.data)
3672
+ execute: async (input) => {
3673
+ const address = parseAddress16(input.address);
3674
+ const data = input.data.map((b) => parseByte(b));
3675
+ if (address + data.length - 1 > 65535) {
3676
+ throw new Error("address + data.length must stay within the 16-bit address space");
3677
+ }
3678
+ return await c64Session.writeMemory(address, data);
3679
+ }
3671
3680
  });
3672
3681
  var executeTool = createViceTool({
3673
3682
  id: "execute",
@@ -3714,36 +3723,26 @@ var listBreakpointsTool = createViceTool({
3714
3723
  var breakpointSetTool = createViceTool({
3715
3724
  id: "breakpoint_set",
3716
3725
  description: "Creates an execution breakpoint or read/write watchpoint. Use either (address, length) or (start, end) format. Addresses can be decimal (53248) or hex string with prefix ($D000, 0xD000).",
3717
- inputSchema: z3.object({
3718
- kind: breakpointKindSchema,
3719
- condition: z3.string().optional(),
3720
- label: z3.string().optional(),
3721
- temporary: z3.boolean().default(false),
3722
- enabled: z3.boolean().default(true)
3723
- }).and(
3724
- z3.union([
3725
- z3.object({
3726
- address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3727
- length: z3.number().int().positive().default(1).describe("Size of the breakpoint range in bytes")
3728
- }),
3729
- z3.object({
3730
- start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3731
- end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3732
- })
3733
- ])
3734
- ).transform((input) => {
3735
- if ("start" in input && "end" in input) {
3736
- if (input.end < input.start) {
3737
- throw new Error("End address must be greater than or equal to start address");
3738
- }
3739
- return {
3740
- ...input,
3741
- address: input.start,
3742
- length: input.end - input.start + 1
3743
- };
3744
- }
3745
- return input;
3746
- }),
3726
+ inputSchema: z3.union([
3727
+ z3.object({
3728
+ kind: breakpointKindSchema,
3729
+ address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3730
+ length: z3.number().int().positive().default(1).describe("Size of the breakpoint range in bytes"),
3731
+ condition: z3.string().optional(),
3732
+ label: z3.string().optional(),
3733
+ temporary: z3.boolean().default(false),
3734
+ enabled: z3.boolean().default(true)
3735
+ }),
3736
+ z3.object({
3737
+ kind: breakpointKindSchema,
3738
+ start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3739
+ end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3740
+ condition: z3.string().optional(),
3741
+ label: z3.string().optional(),
3742
+ temporary: z3.boolean().default(false),
3743
+ enabled: z3.boolean().default(true)
3744
+ })
3745
+ ]),
3747
3746
  dataSchema: z3.object({
3748
3747
  breakpoint: breakpointSchema,
3749
3748
  executionState: executionStateSchema,
@@ -3752,7 +3751,36 @@ var breakpointSetTool = createViceTool({
3752
3751
  registers: c64PartialRegisterValueSchema.nullable()
3753
3752
  }),
3754
3753
  execute: async (input) => {
3755
- const result = await c64Session.breakpointSet(input);
3754
+ let normalizedInput;
3755
+ if ("start" in input && "end" in input) {
3756
+ const start = parseAddress16(input.start);
3757
+ const end = parseAddress16(input.end);
3758
+ if (end < start) {
3759
+ throw new Error("End address must be greater than or equal to start address");
3760
+ }
3761
+ normalizedInput = {
3762
+ kind: input.kind,
3763
+ address: start,
3764
+ length: end - start + 1,
3765
+ condition: input.condition,
3766
+ label: input.label,
3767
+ temporary: input.temporary,
3768
+ enabled: input.enabled
3769
+ };
3770
+ } else if ("address" in input && "length" in input) {
3771
+ normalizedInput = {
3772
+ kind: input.kind,
3773
+ address: parseAddress16(input.address),
3774
+ length: input.length,
3775
+ condition: input.condition,
3776
+ label: input.label,
3777
+ temporary: input.temporary,
3778
+ enabled: input.enabled
3779
+ };
3780
+ } else {
3781
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3782
+ }
3783
+ const result = await c64Session.breakpointSet(normalizedInput);
3756
3784
  return {
3757
3785
  breakpoint: normalizeBreakpoint(result.breakpoint),
3758
3786
  executionState: result.executionState,
package/dist/stdio.cjs CHANGED
@@ -210,7 +210,7 @@ function parseAddress16(input) {
210
210
  }
211
211
  return parsed;
212
212
  }
213
- var address16Schema = import_zod2.z.preprocess(parseAddress16, import_zod2.z.number().int().min(0).max(65535)).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
213
+ var address16Schema = import_zod2.z.union([import_zod2.z.number().int().min(0).max(65535), import_zod2.z.string()]).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
214
214
  function parseByte(input) {
215
215
  if (typeof input === "number") {
216
216
  if (!Number.isInteger(input) || input < 0 || input > 255) {
@@ -334,7 +334,7 @@ function parseByte(input) {
334
334
  }
335
335
  ]);
336
336
  }
337
- var byteValueSchema = import_zod2.z.preprocess(parseByte, import_zod2.z.number().int().min(0).max(255)).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
337
+ var byteValueSchema = import_zod2.z.union([import_zod2.z.number().int().min(0).max(255), import_zod2.z.string()]).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
338
338
  var byteArraySchema = import_zod2.z.array(byteValueSchema).describe('Array of byte values in mixed formats: [255, "$FF", "%11111111", 42]');
339
339
  var c64RegisterValueSchema = import_zod2.z.object(
340
340
  Object.fromEntries(
@@ -3643,30 +3643,35 @@ var readMemoryTool = createViceTool({
3643
3643
  start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3644
3644
  end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3645
3645
  })
3646
- ]).transform((input) => {
3647
- if ("start" in input && "end" in input) {
3648
- if (input.end < input.start) {
3649
- throw new Error("End address must be greater than or equal to start address");
3650
- }
3651
- return {
3652
- address: input.start,
3653
- length: input.end - input.start + 1
3654
- };
3655
- }
3656
- return input;
3657
- }).refine((input) => input.address + input.length <= 65536, {
3658
- message: "address + length must stay within the 64K address space",
3659
- path: ["length"]
3660
- }),
3646
+ ]),
3661
3647
  dataSchema: import_zod4.z.object({
3662
3648
  address: address16Schema.describe("Start address of the returned memory chunk"),
3663
3649
  length: import_zod4.z.number().int().min(0).describe("Number of bytes returned"),
3664
3650
  data: byteArraySchema.describe("Raw bytes returned from memory")
3665
3651
  }),
3666
3652
  execute: async (input) => {
3667
- const result = await c64Session.readMemory(input.address, input.address + input.length - 1);
3653
+ let address;
3654
+ let length;
3655
+ if ("start" in input && "end" in input) {
3656
+ const start = parseAddress16(input.start);
3657
+ const end = parseAddress16(input.end);
3658
+ if (end < start) {
3659
+ throw new Error("End address must be greater than or equal to start address");
3660
+ }
3661
+ address = start;
3662
+ length = end - start + 1;
3663
+ } else if ("address" in input && "length" in input) {
3664
+ address = parseAddress16(input.address);
3665
+ length = input.length;
3666
+ } else {
3667
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3668
+ }
3669
+ if (address + length > 65536) {
3670
+ throw new Error("address + length must stay within the 64K address space");
3671
+ }
3672
+ const result = await c64Session.readMemory(address, address + length - 1);
3668
3673
  return {
3669
- address: input.address,
3674
+ address,
3670
3675
  length: result.length,
3671
3676
  data: result.data
3672
3677
  };
@@ -3678,16 +3683,20 @@ var writeMemoryTool = createViceTool({
3678
3683
  inputSchema: import_zod4.z.object({
3679
3684
  address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3680
3685
  data: byteArraySchema.min(1).describe("Bytes to write: decimal (255), hex ($FF, 0xFF), or binary (%11111111, 0b11111111). Mixed formats allowed.")
3681
- }).refine((input) => input.address + input.data.length - 1 <= 65535, {
3682
- message: "address + data.length must stay within the 16-bit address space",
3683
- path: ["data"]
3684
3686
  }),
3685
3687
  dataSchema: import_zod4.z.object({
3686
3688
  worked: import_zod4.z.boolean().describe("Whether the write operation completed successfully"),
3687
- address: address16Schema.describe("Start address where the bytes were written"),
3689
+ address: import_zod4.z.number().int().min(0).max(65535).describe("Start address where the bytes were written"),
3688
3690
  length: import_zod4.z.number().int().min(1).describe("Number of bytes written")
3689
3691
  }).extend(debugStateSchema.shape),
3690
- execute: async (input) => await c64Session.writeMemory(input.address, input.data)
3692
+ execute: async (input) => {
3693
+ const address = parseAddress16(input.address);
3694
+ const data = input.data.map((b) => parseByte(b));
3695
+ if (address + data.length - 1 > 65535) {
3696
+ throw new Error("address + data.length must stay within the 16-bit address space");
3697
+ }
3698
+ return await c64Session.writeMemory(address, data);
3699
+ }
3691
3700
  });
3692
3701
  var executeTool = createViceTool({
3693
3702
  id: "execute",
@@ -3734,36 +3743,26 @@ var listBreakpointsTool = createViceTool({
3734
3743
  var breakpointSetTool = createViceTool({
3735
3744
  id: "breakpoint_set",
3736
3745
  description: "Creates an execution breakpoint or read/write watchpoint. Use either (address, length) or (start, end) format. Addresses can be decimal (53248) or hex string with prefix ($D000, 0xD000).",
3737
- inputSchema: import_zod4.z.object({
3738
- kind: breakpointKindSchema,
3739
- condition: import_zod4.z.string().optional(),
3740
- label: import_zod4.z.string().optional(),
3741
- temporary: import_zod4.z.boolean().default(false),
3742
- enabled: import_zod4.z.boolean().default(true)
3743
- }).and(
3744
- import_zod4.z.union([
3745
- import_zod4.z.object({
3746
- address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3747
- length: import_zod4.z.number().int().positive().default(1).describe("Size of the breakpoint range in bytes")
3748
- }),
3749
- import_zod4.z.object({
3750
- start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3751
- end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3752
- })
3753
- ])
3754
- ).transform((input) => {
3755
- if ("start" in input && "end" in input) {
3756
- if (input.end < input.start) {
3757
- throw new Error("End address must be greater than or equal to start address");
3758
- }
3759
- return {
3760
- ...input,
3761
- address: input.start,
3762
- length: input.end - input.start + 1
3763
- };
3764
- }
3765
- return input;
3766
- }),
3746
+ inputSchema: import_zod4.z.union([
3747
+ import_zod4.z.object({
3748
+ kind: breakpointKindSchema,
3749
+ address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3750
+ length: import_zod4.z.number().int().positive().default(1).describe("Size of the breakpoint range in bytes"),
3751
+ condition: import_zod4.z.string().optional(),
3752
+ label: import_zod4.z.string().optional(),
3753
+ temporary: import_zod4.z.boolean().default(false),
3754
+ enabled: import_zod4.z.boolean().default(true)
3755
+ }),
3756
+ import_zod4.z.object({
3757
+ kind: breakpointKindSchema,
3758
+ start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3759
+ end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3760
+ condition: import_zod4.z.string().optional(),
3761
+ label: import_zod4.z.string().optional(),
3762
+ temporary: import_zod4.z.boolean().default(false),
3763
+ enabled: import_zod4.z.boolean().default(true)
3764
+ })
3765
+ ]),
3767
3766
  dataSchema: import_zod4.z.object({
3768
3767
  breakpoint: breakpointSchema,
3769
3768
  executionState: executionStateSchema,
@@ -3772,7 +3771,36 @@ var breakpointSetTool = createViceTool({
3772
3771
  registers: c64PartialRegisterValueSchema.nullable()
3773
3772
  }),
3774
3773
  execute: async (input) => {
3775
- const result = await c64Session.breakpointSet(input);
3774
+ let normalizedInput;
3775
+ if ("start" in input && "end" in input) {
3776
+ const start = parseAddress16(input.start);
3777
+ const end = parseAddress16(input.end);
3778
+ if (end < start) {
3779
+ throw new Error("End address must be greater than or equal to start address");
3780
+ }
3781
+ normalizedInput = {
3782
+ kind: input.kind,
3783
+ address: start,
3784
+ length: end - start + 1,
3785
+ condition: input.condition,
3786
+ label: input.label,
3787
+ temporary: input.temporary,
3788
+ enabled: input.enabled
3789
+ };
3790
+ } else if ("address" in input && "length" in input) {
3791
+ normalizedInput = {
3792
+ kind: input.kind,
3793
+ address: parseAddress16(input.address),
3794
+ length: input.length,
3795
+ condition: input.condition,
3796
+ label: input.label,
3797
+ temporary: input.temporary,
3798
+ enabled: input.enabled
3799
+ };
3800
+ } else {
3801
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3802
+ }
3803
+ const result = await c64Session.breakpointSet(normalizedInput);
3776
3804
  return {
3777
3805
  breakpoint: normalizeBreakpoint(result.breakpoint),
3778
3806
  executionState: result.executionState,
package/dist/stdio.js CHANGED
@@ -187,7 +187,7 @@ function parseAddress16(input) {
187
187
  }
188
188
  return parsed;
189
189
  }
190
- var address16Schema = z2.preprocess(parseAddress16, z2.number().int().min(0).max(65535)).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
190
+ var address16Schema = z2.union([z2.number().int().min(0).max(65535), z2.string()]).describe("16-bit C64 address: decimal (53248) or hex string with prefix ($D000, 0xD000)");
191
191
  function parseByte(input) {
192
192
  if (typeof input === "number") {
193
193
  if (!Number.isInteger(input) || input < 0 || input > 255) {
@@ -311,7 +311,7 @@ function parseByte(input) {
311
311
  }
312
312
  ]);
313
313
  }
314
- var byteValueSchema = z2.preprocess(parseByte, z2.number().int().min(0).max(255)).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
314
+ var byteValueSchema = z2.union([z2.number().int().min(0).max(255), z2.string()]).describe("8-bit byte value: decimal (255), hex with prefix ($FF, 0xFF), or binary with prefix (%11111111, 0b11111111)");
315
315
  var byteArraySchema = z2.array(byteValueSchema).describe('Array of byte values in mixed formats: [255, "$FF", "%11111111", 42]');
316
316
  var c64RegisterValueSchema = z2.object(
317
317
  Object.fromEntries(
@@ -3620,30 +3620,35 @@ var readMemoryTool = createViceTool({
3620
3620
  start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3621
3621
  end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3622
3622
  })
3623
- ]).transform((input) => {
3624
- if ("start" in input && "end" in input) {
3625
- if (input.end < input.start) {
3626
- throw new Error("End address must be greater than or equal to start address");
3627
- }
3628
- return {
3629
- address: input.start,
3630
- length: input.end - input.start + 1
3631
- };
3632
- }
3633
- return input;
3634
- }).refine((input) => input.address + input.length <= 65536, {
3635
- message: "address + length must stay within the 64K address space",
3636
- path: ["length"]
3637
- }),
3623
+ ]),
3638
3624
  dataSchema: z3.object({
3639
3625
  address: address16Schema.describe("Start address of the returned memory chunk"),
3640
3626
  length: z3.number().int().min(0).describe("Number of bytes returned"),
3641
3627
  data: byteArraySchema.describe("Raw bytes returned from memory")
3642
3628
  }),
3643
3629
  execute: async (input) => {
3644
- const result = await c64Session.readMemory(input.address, input.address + input.length - 1);
3630
+ let address;
3631
+ let length;
3632
+ if ("start" in input && "end" in input) {
3633
+ const start = parseAddress16(input.start);
3634
+ const end = parseAddress16(input.end);
3635
+ if (end < start) {
3636
+ throw new Error("End address must be greater than or equal to start address");
3637
+ }
3638
+ address = start;
3639
+ length = end - start + 1;
3640
+ } else if ("address" in input && "length" in input) {
3641
+ address = parseAddress16(input.address);
3642
+ length = input.length;
3643
+ } else {
3644
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3645
+ }
3646
+ if (address + length > 65536) {
3647
+ throw new Error("address + length must stay within the 64K address space");
3648
+ }
3649
+ const result = await c64Session.readMemory(address, address + length - 1);
3645
3650
  return {
3646
- address: input.address,
3651
+ address,
3647
3652
  length: result.length,
3648
3653
  data: result.data
3649
3654
  };
@@ -3655,16 +3660,20 @@ var writeMemoryTool = createViceTool({
3655
3660
  inputSchema: z3.object({
3656
3661
  address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3657
3662
  data: byteArraySchema.min(1).describe("Bytes to write: decimal (255), hex ($FF, 0xFF), or binary (%11111111, 0b11111111). Mixed formats allowed.")
3658
- }).refine((input) => input.address + input.data.length - 1 <= 65535, {
3659
- message: "address + data.length must stay within the 16-bit address space",
3660
- path: ["data"]
3661
3663
  }),
3662
3664
  dataSchema: z3.object({
3663
3665
  worked: z3.boolean().describe("Whether the write operation completed successfully"),
3664
- address: address16Schema.describe("Start address where the bytes were written"),
3666
+ address: z3.number().int().min(0).max(65535).describe("Start address where the bytes were written"),
3665
3667
  length: z3.number().int().min(1).describe("Number of bytes written")
3666
3668
  }).extend(debugStateSchema.shape),
3667
- execute: async (input) => await c64Session.writeMemory(input.address, input.data)
3669
+ execute: async (input) => {
3670
+ const address = parseAddress16(input.address);
3671
+ const data = input.data.map((b) => parseByte(b));
3672
+ if (address + data.length - 1 > 65535) {
3673
+ throw new Error("address + data.length must stay within the 16-bit address space");
3674
+ }
3675
+ return await c64Session.writeMemory(address, data);
3676
+ }
3668
3677
  });
3669
3678
  var executeTool = createViceTool({
3670
3679
  id: "execute",
@@ -3711,36 +3720,26 @@ var listBreakpointsTool = createViceTool({
3711
3720
  var breakpointSetTool = createViceTool({
3712
3721
  id: "breakpoint_set",
3713
3722
  description: "Creates an execution breakpoint or read/write watchpoint. Use either (address, length) or (start, end) format. Addresses can be decimal (53248) or hex string with prefix ($D000, 0xD000).",
3714
- inputSchema: z3.object({
3715
- kind: breakpointKindSchema,
3716
- condition: z3.string().optional(),
3717
- label: z3.string().optional(),
3718
- temporary: z3.boolean().default(false),
3719
- enabled: z3.boolean().default(true)
3720
- }).and(
3721
- z3.union([
3722
- z3.object({
3723
- address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3724
- length: z3.number().int().positive().default(1).describe("Size of the breakpoint range in bytes")
3725
- }),
3726
- z3.object({
3727
- start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3728
- end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)")
3729
- })
3730
- ])
3731
- ).transform((input) => {
3732
- if ("start" in input && "end" in input) {
3733
- if (input.end < input.start) {
3734
- throw new Error("End address must be greater than or equal to start address");
3735
- }
3736
- return {
3737
- ...input,
3738
- address: input.start,
3739
- length: input.end - input.start + 1
3740
- };
3741
- }
3742
- return input;
3743
- }),
3723
+ inputSchema: z3.union([
3724
+ z3.object({
3725
+ kind: breakpointKindSchema,
3726
+ address: address16Schema.describe("Start address: decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3727
+ length: z3.number().int().positive().default(1).describe("Size of the breakpoint range in bytes"),
3728
+ condition: z3.string().optional(),
3729
+ label: z3.string().optional(),
3730
+ temporary: z3.boolean().default(false),
3731
+ enabled: z3.boolean().default(true)
3732
+ }),
3733
+ z3.object({
3734
+ kind: breakpointKindSchema,
3735
+ start: address16Schema.describe("Start address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3736
+ end: address16Schema.describe("End address (inclusive): decimal (53248) or hex string with prefix ($D000, 0xD000)"),
3737
+ condition: z3.string().optional(),
3738
+ label: z3.string().optional(),
3739
+ temporary: z3.boolean().default(false),
3740
+ enabled: z3.boolean().default(true)
3741
+ })
3742
+ ]),
3744
3743
  dataSchema: z3.object({
3745
3744
  breakpoint: breakpointSchema,
3746
3745
  executionState: executionStateSchema,
@@ -3749,7 +3748,36 @@ var breakpointSetTool = createViceTool({
3749
3748
  registers: c64PartialRegisterValueSchema.nullable()
3750
3749
  }),
3751
3750
  execute: async (input) => {
3752
- const result = await c64Session.breakpointSet(input);
3751
+ let normalizedInput;
3752
+ if ("start" in input && "end" in input) {
3753
+ const start = parseAddress16(input.start);
3754
+ const end = parseAddress16(input.end);
3755
+ if (end < start) {
3756
+ throw new Error("End address must be greater than or equal to start address");
3757
+ }
3758
+ normalizedInput = {
3759
+ kind: input.kind,
3760
+ address: start,
3761
+ length: end - start + 1,
3762
+ condition: input.condition,
3763
+ label: input.label,
3764
+ temporary: input.temporary,
3765
+ enabled: input.enabled
3766
+ };
3767
+ } else if ("address" in input && "length" in input) {
3768
+ normalizedInput = {
3769
+ kind: input.kind,
3770
+ address: parseAddress16(input.address),
3771
+ length: input.length,
3772
+ condition: input.condition,
3773
+ label: input.label,
3774
+ temporary: input.temporary,
3775
+ enabled: input.enabled
3776
+ };
3777
+ } else {
3778
+ throw new Error("Invalid input: must provide either (address, length) or (start, end)");
3779
+ }
3780
+ const result = await c64Session.breakpointSet(normalizedInput);
3753
3781
  return {
3754
3782
  breakpoint: normalizeBreakpoint(result.breakpoint),
3755
3783
  executionState: result.executionState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c64-debug-mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Model Context Protocol server for C64 debugging via VICE emulator",
5
5
  "type": "module",
6
6
  "keywords": [