```ts
export function runTransactions(commands: string[]): Record<string, string> {
  const store: Record<string, string> = {};
  const transactionStack: Array<Record<string, string>> = [];

  for (const command of commands) {
    const parts = command.split(' ');

    if (parts.length < 2) {
      throw new Error(`Invalid command: ${command}`);
    }

    const [verb, key, value] = parts;

    switch (verb) {
      case 'set':
        if (parts.length !== 3) {
          throw new Error(`Invalid command: ${command}`);
        }
        if (transactionStack.length > 0) {
          transactionStack[transactionStack.length - 1][key] = value;
        } else {
          store[key] = value;
        }
        break;

      case 'unset':
        if (parts.length !== 2) {
          throw new Error(`Invalid command: ${command}`);
        }
        if (transactionStack.length > 0) {
          delete transactionStack[transactionStack.length - 1][key];
        } else {
          delete store[key];
        }
        break;

      case 'begin':
        if (parts.length !== 1) {
          throw new Error(`Invalid command: ${command}`);
        }
        transactionStack.push({});
        break;

      case 'commit':
        if (parts.length !== 1) {
          throw new Error(`Invalid command: ${command}`);
        }
        if (transactionStack.length === 0) {
          throw new Error('No transaction to commit');
        }
        const lastTransaction = transactionStack.pop()!;
        for (const [k, v] of Object.entries(lastTransaction)) {
          store[k] = v;
        }
        break;

      case 'rollback':
        if (parts.length !== 1) {
          throw new Error(`Invalid command: ${command}`);
        }
        if (transactionStack.length === 0) {
          throw new Error('No transaction to rollback');
        }
        transactionStack.pop();
        break;

      default:
        throw new Error(`Unknown command: ${verb}`);
    }
  }

  if (transactionStack.length > 0) {
    throw new Error('Transaction still open after the last command');
  }

  return store;
}
```